Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pszz committed May 15, 2024
1 parent 0e5b0f3 commit 840229a
Show file tree
Hide file tree
Showing 57 changed files with 9,505 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["next/babel"],
"plugins": ["inline-react-svg"]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/public/**/**
/node_modules
.husky
.next
.dist
51 changes: 51 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:prettier/recommended',
'plugin:@next/next/recommended',
],
plugins: ['react-hooks', 'unused-imports'],
rules: {
'no-console': 0,
'import/named': 0,
'import/order': 1,
'import/no-default-export': 0,
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unnecessary-type-constraint': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-unused-vars': 0,
'unused-imports/no-unused-imports': 2,
'unused-imports/no-unused-vars': [
1,
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'react-hooks/rules-of-hooks': 2,
'react-hooks/exhaustive-deps': 1,
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
moduleDirectory: ['node_modules', 'src'],
},
},
},
}
49 changes: 49 additions & 0 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy App To Production

on:
push:
branches: ['main']

jobs:
deploy-production:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@master

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: npx [email protected] build

- name: AWS credentials Setting
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Upload _next to AWS S3
run: |
aws s3 cp .open-next/assets/_next/static/ "s3://${{ secrets.PRODUCTION_AWS_BUCKET }}/_next/static/" --acl bucket-owner-full-control --recursive --cache-control \'public,max-age=31536000,immutable\' --exclude ".git/*"
- name: Upload assets to AWS S3
run: |
aws s3 cp .open-next/assets/ "s3://${{ secrets.PRODUCTION_AWS_BUCKET }}" --acl bucket-owner-full-control --recursive --cache-control \'public,max-age=0,s-maxage=31536000,must-revalidate\' --exclude ".open-next/_next/static/*" --exclude ".git/*"
- name: Packing of lambda function(server function)
run: cd .open-next/server-function && zip -r -9 ../../server-function.zip .

- name: Update lambda function(server function)
run: aws lambda update-function-code --function-name ${{ secrets.PRODUCTION_AWS_LAMBDA_SERVER_FUNCTION }} --zip-file fileb://server-function.zip

- name: Packing of lambda function(image optimization function)
run: cd .open-next/image-optimization-function && zip -r -9 ../../image-optimization-function.zip .

- name: Update lambda function(image optimization function)
run: aws lambda update-function-code --function-name ${{ secrets.PRODUCTION_AWS_LAMBDA_IMAGE_OPTIMIZATION_FUNCTION }} --zip-file fileb://image-optimization-function.zip

- name: Cache Invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.PRODUCTION_AWS_DISTRIBUTION_ID }} --paths "/*"

48 changes: 48 additions & 0 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy App To Staging

on:
push:
branches: ['stage']

jobs:
deploy-staging:
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@master

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: npx [email protected] build

- name: AWS credentials Setting
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Upload _next to AWS S3
run: |
aws s3 cp .open-next/assets/_next/static/ "s3://${{ secrets.STAGING_AWS_BUCKET }}/_next/static/" --acl bucket-owner-full-control --recursive --cache-control \'public,max-age=31536000,immutable\' --exclude ".git/*"
- name: Upload assets to AWS S3
run: |
aws s3 cp .open-next/assets/ "s3://${{ secrets.STAGING_AWS_BUCKET }}" --acl bucket-owner-full-control --recursive --cache-control \'public,max-age=0,s-maxage=31536000,must-revalidate\' --exclude ".open-next/_next/static/*" --exclude ".git/*"
- name: Packing of lambda function(server function)
run: cd .open-next/server-function && zip -r -9 ../../server-function.zip .

- name: Update lambda function(server function)
run: aws lambda update-function-code --function-name ${{ secrets.STAGING_AWS_LAMBDA_SERVER_FUNCTION }} --zip-file fileb://server-function.zip

- name: Packing of lambda function(image optimization function)
run: cd .open-next/image-optimization-function && zip -r -9 ../../image-optimization-function.zip .

- name: Update lambda function(image optimization function)
run: aws lambda update-function-code --function-name ${{ secrets.STAGING_AWS_LAMBDA_IMAGE_OPTIMIZATION_FUNCTION }} --zip-file fileb://image-optimization-function.zip

- name: Cache Invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGING_AWS_DISTRIBUTION_ID }} --paths "/*"
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.yarn
.DS_Store
*.pem

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

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
*.swp
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "all",
"semi": false,
"singleQuote": true,
"printWidth": 120,
"endOfLine": "auto"
}
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev"
},
{
"name": "Next.js: debug client-side",
"type": "pwa-chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"console": "integratedTerminal",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}
44 changes: 44 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"files.exclude": {
"**/.git": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/node_modules": true,
"**/*.log": true,
"**/.next": true,
"**/.github": true,
"**/.husky": true,
"**/.yarn": true,
"**/.babelrc": true,
"**/.editorconfig": true,
"**/.eslintignore": true,
"**/.yarnrc.yml": true,
"**/commitlint.config.js": true,
"**/next-env.d.ts": true,
"**/.vscode": true,
"**/.gitignore": true,
"tsconfig.json": true,
".eslintrc.js": true,
"build": true,
"dist": true,
"customHttp.yml": true,
".prettierrc": true
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"typescript.tsdk": "node_modules/typescript/lib"
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Why use NextJS-Template?

1. Nextjs

2. `.github`

2. `.husky`

3. `.vscode`

4. `.prettierrc`

5. `.eslintrc`

6. `Google analytics` [Need to configure `code`]

7. `Alias path: @/*`

8. `Webpack SVGR`

9. `sentry` [Need to configure `SENTRY_DSN`]

10. `<Toast />` and `<Table />`

11. `robots.txt` && `sitemap.xml`

12. `github workfolow`

13. `favicon.svg`

14. `404 page`

15. `Mui Themes`

16. `Web3 Wagmi/Viem/ConnectKit`
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
}
33 changes: 33 additions & 0 deletions customHttp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
customHeaders:
- pattern: '/'
headers:
- key: 'Strict-Transport-Security'
value: 'max-age=31536000; includeSubDomains'
- key: 'X-Frame-Options'
value: 'SAMEORIGIN'
- key: 'Cache-Control'
value: 'public, max-age=0, s-maxage=300, must-revalidate'
- pattern: '/imgs/**/*'
headers:
- key: 'Strict-Transport-Security'
value: 'max-age=31536000; includeSubDomains'
- key: 'X-Frame-Options'
value: 'SAMEORIGIN'
- key: 'Cache-Control'
value: 'public, max-age=30, s-maxage=300, stale-while-revalidate'
- pattern: '/_next/static/**/*'
headers:
- key: 'Strict-Transport-Security'
value: 'max-age=31536000; includeSubDomains'
- key: 'X-Frame-Options'
value: 'SAMEORIGIN'
- key: 'Cache-Control'
value: 'public, max-age=31536000, s-maxage=31536000, immutable'
- pattern: '/favicon.svg'
headers:
- key: 'Strict-Transport-Security'
value: 'max-age=31536000; includeSubDomains'
- key: 'X-Frame-Options'
value: 'SAMEORIGIN'
- key: 'Cache-Control'
value: 'public, max-age=300, s-maxage=86400, stale-while-revalidate'
5 changes: 5 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
Loading

0 comments on commit 840229a

Please sign in to comment.