Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
40229fb
task2: added s3 bucket and cloudfront distribution
Ilya-Valasiuk Mar 16, 2021
50d2a7a
add comments about custom plugins
Ilya-Valasiuk Mar 17, 2021
05ca160
Merge pull request #1 from EPAM-JS-Competency-center/task-2
Mar 18, 2021
778af13
use regional domain name for s3 bucket in cf distribution
Ilya-Valasiuk Apr 3, 2021
c604116
Merge branch 'main' of github.com:EPAM-JS-Competency-center/shop-reac…
Ilya-Valasiuk Apr 3, 2021
f5749cf
Merge pull request #2 from EPAM-JS-Competency-center/task2-cf-issue
Ilya-Valasiuk Apr 10, 2021
35a645f
Update typescript version
vladshcherbin Aug 13, 2021
4553a25
Update useParams hook typings
vladshcherbin Aug 13, 2021
ae039bb
Merge pull request #29 from vladshcherbin/typescript-errors
SergeyKovalchuk Aug 15, 2021
951ebf9
Replace CRA with vite
AlexandrLi Jul 5, 2022
6260f76
Migrate to mui v5
AlexandrLi Jul 5, 2022
87523cf
Add eslint and prettier configs
AlexandrLi Jul 5, 2022
4e27f32
Migrate to react-router v6
AlexandrLi Jul 6, 2022
567c4cc
clean up code
AlexandrLi Jul 6, 2022
3ee1d97
Add msw as a mock-server
AlexandrLi Jul 6, 2022
5ab872e
Add react-query
AlexandrLi Jul 6, 2022
b8aa162
Remove redux in favor of react-query
AlexandrLi Jul 7, 2022
088b400
Migrate to React 18
AlexandrLi Jul 7, 2022
5c9a441
Migrate to the latest serverless version
AlexandrLi Jul 9, 2022
939e42f
Setup tests. Fix small issues
AlexandrLi Jul 9, 2022
ae777a2
Update README.md
AlexandrLi Jul 10, 2022
e10d6a8
Fix routing issues
AlexandrLi Jul 10, 2022
f17de8e
Merge pull request #120 from AlexandrLi/update-stack
SergeyKovalchuk Jul 14, 2022
1aa0843
chore: delete serverless scripts from package.json
ThorsAngerVaNeT Apr 5, 2023
d10cb82
chore: delete serverless dependencies
ThorsAngerVaNeT Apr 5, 2023
dfc7ccb
chore: delete serverless files
ThorsAngerVaNeT Apr 5, 2023
449dcb0
docs: delete serverless scripts from README.md
ThorsAngerVaNeT Apr 5, 2023
d6e17ba
Merge pull request #1 from rolling-scopes-school/remove-serverless
ThorsAngerVaNeT Apr 5, 2023
001e313
Added statis site deployment
BorysovskaOA Apr 26, 2026
c7ccc14
Connected get products to gateway api
BorysovskaOA Apr 29, 2026
2a45fc1
Changed by id route as well
BorysovskaOA Apr 29, 2026
ecbf036
Merge pull request #1 from BorysovskaOA/task-2
BorysovskaOA Apr 29, 2026
bc07ac8
Change api gateway url and fixed create product
BorysovskaOA May 15, 2026
8baf043
Fixed url
BorysovskaOA May 15, 2026
e5b0918
Merge pull request #2 from BorysovskaOA/task3
BorysovskaOA May 15, 2026
4b26fb4
Merge pull request #3 from BorysovskaOA/change-gateway-api-url
BorysovskaOA May 15, 2026
d7af920
Connected import API
BorysovskaOA May 16, 2026
d762689
Create workspase for infra and new command to deploy from main folder…
BorysovskaOA May 20, 2026
613dd3c
Added handling 401/403
BorysovskaOA May 30, 2026
fe402de
Fixed authorization token
BorysovskaOA May 30, 2026
c814a2a
Fixed no token
BorysovskaOA May 30, 2026
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
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
public
vite.config.ts
serverless.yml
24 changes: 24 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:prettier/recommended",
"prettier"
],
"plugins": ["@typescript-eslint", "react", "prettier"],
"env": {
"browser": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
}
}
43 changes: 21 additions & 22 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
build
.serverless
coverage
dist
dist-ssr
*.local

# misc
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

/.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
77 changes: 52 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,72 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
# React-shop-cloudfront

This is frontend starter project for nodejs-aws mentoring program. It uses the following technologies:

- [Vite](https://vitejs.dev/) as a project bundler
- [React](https://beta.reactjs.org/) as a frontend framework
- [React-router-dom](https://reactrouterdotcom.fly.dev/) as a routing library
- [MUI](https://mui.com/) as a UI framework
- [React-query](https://react-query-v3.tanstack.com/) as a data fetching library
- [Formik](https://formik.org/) as a form library
- [Yup](https://github.com/jquense/yup) as a validation schema
- [Vitest](https://vitest.dev/) as a test runner
- [MSW](https://mswjs.io/) as an API mocking library
- [Eslint](https://eslint.org/) as a code linting tool
- [Prettier](https://prettier.io/) as a code formatting tool
- [TypeScript](https://www.typescriptlang.org/) as a type checking tool

## Available Scripts

In the project directory, you can run:
You can use NPM instead of YARN (Up to you)
### `start`

### `yarn start` OR `npm run start`
Starts the project in dev mode with mocked API on local environment.

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
### `build`

The page will reload if you make edits.<br />
You will also see any lint errors in the console.
Builds the project for production in `dist` folder.

### `yarn test` OR `npm run test`
### `preview`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
Starts the project in production mode on local environment.

### `yarn build` OR `npm run build`
### `test`, `test:ui`, `test:coverage`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
Runs tests in console, in browser or with coverage.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
### `lint`, `prettier`

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
Runs linting and formatting for all files in `src` folder.

### `yarn eject` OR `npm run eject`
## Infra

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
Link to S3: https://nodejsawsshopreactstack-nodejsawsshopreactbucket3f-zmwqh1s5qceo.s3.eu-north-1.amazonaws.com/
Should not have public access

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Link to CF: https://d180fy39z34bng.cloudfront.net/
Should have public acess

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
## Available infra scripts:

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
### Prerequisites

## Learn More
!!!Needs latest verison of the source to work with updated `dist` folder.
1. Build project
```npm run build```
2. Go to infra folder:
```cd infra```

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
### `bootstrap`

To learn React, check out the [React documentation](https://reactjs.org/).
Prepares your AWS account for CDK. Creates the necessary resources to store assets during deployment.

### `diff`

Compares the specified stack and its dependencies with the deployed stack. Use this to visualize infrastructure changes before applying them.

### `deploy`

Deploys the infrastructure resources to your AWS account based on the defined stacks.

### `destroy`

Removes all AWS resources associated with the stacks to ensure no infrastructure is left behind.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My shop</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions infra/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/cdk.out
7 changes: 7 additions & 0 deletions infra/bin/infra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "source-map-support/register";
import * as cdk from "aws-cdk-lib";
import { WebStack } from "../lib/web-stack";

const app = new cdk.App();

new WebStack(app, "NodeJsAwsShopReactStack");
3 changes: 3 additions & 0 deletions infra/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"app": "npx ts-node --prefer-ts-exts bin/infra.ts"
}
50 changes: 50 additions & 0 deletions infra/lib/web-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as cdk from "aws-cdk-lib";
import * as s3 from "aws-cdk-lib/aws-s3";
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as origins from "aws-cdk-lib/aws-cloudfront-origins";
import * as s3deploy from "aws-cdk-lib/aws-s3-deployment";
import { Construct } from "constructs";
import * as path from "path";

export class WebStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const bucket = new s3.Bucket(this, "NodeJsAwsShopReactBucket", {
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
});

const distribution = new cloudfront.Distribution(
this,
"NodeJsAwsShopReactDist",
{
defaultBehavior: {
origin: origins.S3BucketOrigin.withOriginAccessControl(bucket),
viewerProtocolPolicy:
cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
},
defaultRootObject: "index.html",
errorResponses: [
{
httpStatus: 403,
responseHttpStatus: 200,
responsePagePath: "/index.html",
},
],
}
);

new s3deploy.BucketDeployment(this, "DeployNodeJsAwsShopReact", {
sources: [s3deploy.Source.asset(path.join(__dirname, "../../dist"))],
destinationBucket: bucket,
distribution,
distributionPaths: ["/*"],
});

new cdk.CfnOutput(this, "NodeJsAwsShopReactDomainName", {
value: distribution.distributionDomainName,
});
}
}
27 changes: 27 additions & 0 deletions infra/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "nodejs-aws-shop-react-infra",
"version": "1.0.0",
"author": "BorysovskaOA",
"private": true,
"bin": {
"infra": "bin/infra.js"
},
"scripts": {
"cdk": "cdk",
"bootstrap": "npx cdk bootstrap",
"deploy": "cdk deploy",
"destroy": "cdk destroy",
"diff": "cdk diff"
},
"dependencies": {
"aws-cdk-lib": "^2.251.0",
"constructs": "^10.6.0",
"source-map-support": "^0.5.21"
},
"devDependencies": {
"@types/node": "^25.6.0",
"aws-cdk": "^2.1119.0",
"ts-node": "^10.9.2",
"typescript": "^6.0.3"
}
}
13 changes: 13 additions & 0 deletions infra/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"lib": ["ES2020"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"types": ["node"]
},
"exclude": ["node_modules", "cdk.out"]
}
Loading