Skip to content

Commit 10f330f

Browse files
authored
Add nextjs app and pages version of the app (#198)
* add nextjs version with pages folder * update ci * fix head * update tests * add public page with ssr * update * rename app folder * update docs * update * init nextjs-app from nextjs-pages * migrate nextjs app * fix linting * update * more updates * update readme * update docs * use fetch api instead of axios * cleanup
1 parent ea1ebba commit 10f330f

File tree

344 files changed

+40452
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+40452
-48
lines changed

.github/workflows/nextjs-app-ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Next.js App CI
2+
on:
3+
push:
4+
branches: ["*"]
5+
paths-ignore:
6+
- "README.md"
7+
- "docs/**"
8+
pull_request:
9+
branches: [master]
10+
paths-ignore:
11+
- "README.md"
12+
- "docs/**"
13+
jobs:
14+
all-cli-checks:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./apps/nextjs-app
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: lts/*
24+
- name: Set environment variables
25+
run: mv .env.example .env
26+
- name: Install dependencies
27+
run: yarn install
28+
- name: Build application
29+
run: yarn build
30+
- name: Run tests
31+
run: yarn test
32+
- name: Run linter
33+
run: yarn lint
34+
- name: Check types
35+
run: yarn check-types
36+
e2e:
37+
timeout-minutes: 60
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: ./apps/nextjs-app
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: lts/*
47+
- name: Set environment variables
48+
run: mv .env.example-e2e .env
49+
- name: Install dependencies
50+
run: npm install -g yarn && yarn
51+
- name: Install Playwright Browsers
52+
run: yarn playwright install --with-deps
53+
- name: Run Playwright tests
54+
run: yarn test-e2e
55+
- uses: actions/upload-artifact@v4
56+
if: always()
57+
with:
58+
name: playwright-report
59+
path: |
60+
playwright-report/
61+
mocked-db.json
62+
retention-days: 30

.github/workflows/nextjs-pages-ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Next.js Pages CI
2+
on:
3+
push:
4+
branches: ["*"]
5+
paths-ignore:
6+
- "README.md"
7+
- "docs/**"
8+
pull_request:
9+
branches: [master]
10+
paths-ignore:
11+
- "README.md"
12+
- "docs/**"
13+
jobs:
14+
all-cli-checks:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./apps/nextjs-pages
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: lts/*
24+
- name: Set environment variables
25+
run: mv .env.example .env
26+
- name: Install dependencies
27+
run: yarn install
28+
- name: Build application
29+
run: yarn build
30+
- name: Run tests
31+
run: yarn test
32+
- name: Run linter
33+
run: yarn lint
34+
- name: Check types
35+
run: yarn check-types
36+
e2e:
37+
timeout-minutes: 60
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: ./apps/nextjs-pages
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: lts/*
47+
- name: Set environment variables
48+
run: mv .env.example-e2e .env
49+
- name: Install dependencies
50+
run: npm install -g yarn && yarn
51+
- name: Install Playwright Browsers
52+
run: yarn playwright install --with-deps
53+
- name: Run Playwright tests
54+
run: yarn test-e2e
55+
- uses: actions/upload-artifact@v4
56+
if: always()
57+
with:
58+
name: playwright-report
59+
path: |
60+
playwright-report/
61+
mocked-db.json
62+
retention-days: 30

.github/workflows/ci.yml renamed to .github/workflows/react-vite-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: React Vite CI
22
on:
33
push:
44
branches: ["*"]
@@ -11,7 +11,7 @@ on:
1111
- "README.md"
1212
- "docs/**"
1313
jobs:
14-
all-cli-check:
14+
all-cli-checks:
1515
runs-on: ubuntu-latest
1616
defaults:
1717
run:

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
yarn --cwd apps/react-vite lint-staged
1+
yarn --cwd apps/nextjs-app lint-staged && yarn --cwd apps/nextjs-pages lint-staged && yarn --cwd apps/react-vite lint-staged

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ This repo doesn't aim to be a silver bullet for all React applications as there
2424
- Uses the right tools for the job
2525
- Clean boundaries between different parts of the application
2626
- Everyone on the team is on the same page when it comes to how things are done
27-
- Security
28-
- Performance
29-
- Scalability in terms of codebase and team size
27+
- Secure
28+
- Performant
29+
- Scalable in terms of codebase and team size
3030
- Issues detectable as early as possible
3131

3232
#### Disclaimer:
@@ -56,9 +56,10 @@ Contributions are always welcome! If you have any ideas, suggestions, fixes, fee
5656

5757
1. Clone this repo
5858
2. Create a branch: `git checkout -b your-feature`
59-
3. Make some changes
60-
4. Test your changes
61-
5. Push your branch and open a Pull Request
59+
3. Execute the `yarn prepare` script.
60+
4. Make some changes
61+
5. Test your changes
62+
6. Push your branch and open a Pull Request
6263

6364
## License
6465

apps/nextjs-app/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NEXT_PUBLIC_API_URL=http://localhost:8080/api
2+
NEXT_PUBLIC_ENABLE_API_MOCKING=false
3+
NEXT_PUBLIC_MOCK_API_PORT=8080
4+
NEXT_PUBLIC_URL=http://localhost:3000

apps/nextjs-app/.env.example-e2e

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NEXT_PUBLIC_API_URL=http://localhost:8080/api
2+
NEXT_PUBLIC_ENABLE_API_MOCKING=false
3+
NEXT_PUBLIC_MOCK_API_PORT=8080
4+
NEXT_PUBLIC_URL=http://localhost:3000

apps/nextjs-app/.eslintrc.cjs

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
es6: true,
6+
},
7+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
8+
ignorePatterns: [
9+
'node_modules/*',
10+
'public/mockServiceWorker.js',
11+
'generators/*',
12+
],
13+
extends: ['eslint:recommended', 'next/core-web-vitals'],
14+
overrides: [
15+
{
16+
files: ['**/*.ts', '**/*.tsx'],
17+
parser: '@typescript-eslint/parser',
18+
settings: {
19+
react: { version: 'detect' },
20+
'import/resolver': {
21+
typescript: {},
22+
},
23+
},
24+
env: {
25+
browser: true,
26+
node: true,
27+
es6: true,
28+
},
29+
extends: [
30+
'eslint:recommended',
31+
'plugin:import/errors',
32+
'plugin:import/warnings',
33+
'plugin:import/typescript',
34+
'plugin:@typescript-eslint/recommended',
35+
'plugin:react/recommended',
36+
'plugin:react-hooks/recommended',
37+
'plugin:jsx-a11y/recommended',
38+
'plugin:prettier/recommended',
39+
'plugin:testing-library/react',
40+
'plugin:jest-dom/recommended',
41+
'plugin:tailwindcss/recommended',
42+
'plugin:vitest/legacy-recommended',
43+
],
44+
rules: {
45+
'@next/next/no-img-element': 'off',
46+
'import/no-restricted-paths': [
47+
'error',
48+
{
49+
zones: [
50+
// disables cross-feature imports:
51+
// eg. src/features/discussions should not import from src/features/comments, etc.
52+
{
53+
target: './src/features/auth',
54+
from: './src/features',
55+
except: ['./auth'],
56+
},
57+
{
58+
target: './src/features/comments',
59+
from: './src/features',
60+
except: ['./comments'],
61+
},
62+
{
63+
target: './src/features/discussions',
64+
from: './src/features',
65+
except: ['./discussions'],
66+
},
67+
{
68+
target: './src/features/teams',
69+
from: './src/features',
70+
except: ['./teams'],
71+
},
72+
{
73+
target: './src/features/users',
74+
from: './src/features',
75+
except: ['./users'],
76+
},
77+
// enforce unidirectional codebase:
78+
79+
// e.g. src/app can import from src/features but not the other way around
80+
{
81+
target: './src/features',
82+
from: './src/app',
83+
},
84+
85+
// e.g src/features and src/app can import from these shared modules but not the other way around
86+
{
87+
target: [
88+
'./src/components',
89+
'./src/hooks',
90+
'./src/lib',
91+
'./src/types',
92+
'./src/utils',
93+
],
94+
from: ['./src/features', './src/app'],
95+
},
96+
],
97+
},
98+
],
99+
'import/no-cycle': 'error',
100+
'linebreak-style': ['error', 'unix'],
101+
'react/prop-types': 'off',
102+
'import/order': [
103+
'error',
104+
{
105+
groups: [
106+
'builtin',
107+
'external',
108+
'internal',
109+
'parent',
110+
'sibling',
111+
'index',
112+
'object',
113+
],
114+
'newlines-between': 'always',
115+
alphabetize: { order: 'asc', caseInsensitive: true },
116+
},
117+
],
118+
'import/default': 'off',
119+
'import/no-named-as-default-member': 'off',
120+
'import/no-named-as-default': 'off',
121+
'react/react-in-jsx-scope': 'off',
122+
'jsx-a11y/anchor-is-valid': 'off',
123+
'@typescript-eslint/no-unused-vars': ['error'],
124+
'@typescript-eslint/explicit-function-return-type': ['off'],
125+
'@typescript-eslint/explicit-module-boundary-types': ['off'],
126+
'@typescript-eslint/no-empty-function': ['off'],
127+
'@typescript-eslint/no-explicit-any': ['off'],
128+
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
129+
},
130+
},
131+
{
132+
plugins: ['check-file'],
133+
files: ['src/**/*'],
134+
rules: {
135+
'check-file/filename-naming-convention': [
136+
'error',
137+
{
138+
'**/*.{ts,tsx}': 'KEBAB_CASE',
139+
},
140+
{
141+
ignoreMiddleExtensions: true,
142+
},
143+
],
144+
'check-file/folder-naming-convention': [
145+
'error',
146+
{
147+
'!(src/app)/**/*': 'KEBAB_CASE',
148+
'!(**/__tests__)/**/*': 'KEBAB_CASE',
149+
},
150+
],
151+
},
152+
},
153+
],
154+
};

apps/nextjs-app/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
/test-results/
11+
/playwright-report/
12+
/blob-report/
13+
/playwright/.cache/
14+
/e2e/.auth/
15+
16+
# storybook
17+
migration-storybook.log
18+
storybook.log
19+
storybook-static
20+
21+
22+
# production
23+
/dist
24+
25+
# misc
26+
.DS_Store
27+
.env
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
npm-debug.log*
34+
yarn-debug.log*
35+
yarn-error.log*
36+
37+
38+
# local
39+
mocked-db.json
40+
41+
/.next
42+
/.vite
43+
tsconfig.tsbuildinfo

apps/nextjs-app/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.hbs

0 commit comments

Comments
 (0)