Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudFormation resource names #40

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"last 1 safari version"
]
},
"proxy": "https://jsonplaceholder.typicode.com",
"jest": {
"coveragePathIgnorePatterns": [
"node_modules",
Expand Down
4 changes: 3 additions & 1 deletion src/api/useGetUser.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -37,10 +38,11 @@ interface UseGetUserProps {

export const useGetUser = ({ userId }: UseGetUserProps): UseQueryResult<User, Error> => {
const axios = useAxios();
const config = useConfig();

const getUser = async (id: number): Promise<User | null> => {
const response = await axios.request({
url: `/users/${id}`,
url: `${config.REACT_APP_BASE_URL_API}/users/${id}`,
});
return response.data;
};
Expand Down
2 changes: 2 additions & 0 deletions src/providers/ConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +23,7 @@ export interface Config {
* @see {@link https://github.com/jquense/yup | Yup}
*/
const configSchema: ObjectSchema<Config> = 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'),
Expand Down
15 changes: 7 additions & 8 deletions template.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Description: LSuite UI component resources
Description: React Starter UI component resources

Parameters:
EnvironmentCode:
Expand Down Expand Up @@ -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]

##
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -175,7 +175,6 @@ Resources:
DomainName: !Sub
- 'api.${HostedZone}'
- HostedZone: !FindInMap [EnvironmentAttributeMap, !Ref EnvironmentCode, HostedZone]

Id: CUSTOM-API
PriceClass: PriceClass_100
ViewerCertificate:
Expand All @@ -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:
Expand All @@ -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:
Expand Down