From 476bb78fe72fedc49f0800b6900a6a84ee995692 Mon Sep 17 00:00:00 2001 From: Matthew Warman Date: Thu, 14 Mar 2024 10:58:15 -0400 Subject: [PATCH 1/2] CFN template updates --- template.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/template.yml b/template.yml index 1da0508..028928a 100644 --- a/template.yml +++ b/template.yml @@ -1,4 +1,4 @@ -Description: LSuite UI component resources +Description: React Starter UI component resources Parameters: EnvironmentCode: @@ -34,7 +34,7 @@ Resources: Type: AWS::S3::Bucket Properties: BucketName: !Sub - - 'lsuite-ui-app.${HostedZone}-${AWS::Region}-${AWS::AccountId}' + - 'reactstarter-ui-app.${HostedZone}-${AWS::Region}-${AWS::AccountId}' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] ## @@ -67,7 +67,7 @@ Resources: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: - Comment: !Sub 'LSuite UI SPA (${EnvironmentCode})' + Comment: !Sub 'React Starter UI SPA (${EnvironmentCode})' CustomErrorResponses: - ErrorCode: 404 ResponsePagePath: '/index.html' @@ -107,10 +107,10 @@ Resources: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: - Comment: !Sub 'LSuite UI App (${EnvironmentCode})' + Comment: !Sub 'React Starter UI App (${EnvironmentCode})' Aliases: - !Sub - - 'lsuite.${HostedZone}' + - 'react-starter.${HostedZone}' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] CacheBehaviors: - AllowedMethods: @@ -175,7 +175,6 @@ Resources: DomainName: !Sub - 'api.${HostedZone}' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] - Id: CUSTOM-API PriceClass: PriceClass_100 ViewerCertificate: @@ -193,7 +192,7 @@ Resources: - '${HostedZone}.' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] Name: !Sub - - 'lsuite.${HostedZone}' + - 'react-starter.${HostedZone}' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] Type: A AliasTarget: @@ -210,7 +209,7 @@ Resources: - '${HostedZone}.' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] Name: !Sub - - 'lsuite.${HostedZone}' + - 'react-starter.${HostedZone}' - HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone] Type: AAAA AliasTarget: From 4a2ae083464e2806fffacb6b8c288162aad45c1e Mon Sep 17 00:00:00 2001 From: Matthew Warman Date: Thu, 14 Mar 2024 11:45:21 -0400 Subject: [PATCH 2/2] API base url --- package.json | 1 - src/api/useGetUser.ts | 4 +++- src/providers/ConfigProvider.tsx | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5b9c54c..feaa200 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "last 1 safari version" ] }, - "proxy": "https://jsonplaceholder.typicode.com", "jest": { "coveragePathIgnorePatterns": [ "node_modules", diff --git a/src/api/useGetUser.ts b/src/api/useGetUser.ts index b67a4b9..0d01085 100644 --- a/src/api/useGetUser.ts +++ b/src/api/useGetUser.ts @@ -1,6 +1,7 @@ import { UseQueryResult, useQuery } from '@tanstack/react-query'; import { useAxios } from 'providers/AxiosProvider'; +import { useConfig } from 'providers/ConfigProvider'; import { QueryKeys } from 'utils/constants'; export type Address = { @@ -37,10 +38,11 @@ interface UseGetUserProps { export const useGetUser = ({ userId }: UseGetUserProps): UseQueryResult => { const axios = useAxios(); + const config = useConfig(); const getUser = async (id: number): Promise => { const response = await axios.request({ - url: `/users/${id}`, + url: `${config.REACT_APP_BASE_URL_API}/users/${id}`, }); return response.data; }; diff --git a/src/providers/ConfigProvider.tsx b/src/providers/ConfigProvider.tsx index 2263b19..d03815a 100644 --- a/src/providers/ConfigProvider.tsx +++ b/src/providers/ConfigProvider.tsx @@ -6,6 +6,7 @@ import { ObjectSchema } from 'yup'; * The application configuration. The `value` provided by the `ConfigContext`. */ export interface Config { + REACT_APP_BASE_URL_API: string; REACT_APP_BUILD_DATE: string; REACT_APP_BUILD_TIME: string; REACT_APP_BUILD_TS: string; @@ -22,6 +23,7 @@ export interface Config { * @see {@link https://github.com/jquense/yup | Yup} */ const configSchema: ObjectSchema = Yup.object({ + REACT_APP_BASE_URL_API: Yup.string().url().required(), REACT_APP_BUILD_DATE: Yup.string().default('1970-01-01'), REACT_APP_BUILD_TIME: Yup.string().default('00:00:00'), REACT_APP_BUILD_TS: Yup.string().default('1970-01-01T00:00:00+0000'),