create-tigra 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +80 -87
- package/bin/create-tigra.js +259 -308
- package/package.json +49 -41
- package/template/_claude/QUICK_REFERENCE.md +193 -0
- package/template/_claude/README.md +53 -0
- package/template/_claude/commands/create-client.md +881 -0
- package/template/_claude/commands/create-server.md +383 -0
- package/template/_claude/rules/client/01-project-structure.md +133 -0
- package/template/_claude/rules/client/02-components-and-types.md +146 -0
- package/template/_claude/rules/client/03-data-and-state.md +156 -0
- package/template/_claude/rules/client/04-design-system.md +185 -0
- package/template/_claude/rules/client/05-security.md +55 -0
- package/template/_claude/rules/client/06-ux-checklist.md +81 -0
- package/template/_claude/rules/client/core.md +42 -0
- package/template/_claude/rules/global/core.md +77 -0
- package/template/_claude/rules/server/core.md +50 -0
- package/template/_claude/rules/server/database.md +124 -0
- package/template/_claude/rules/server/project-conventions.md +150 -0
- package/template/_claude/rules/server/response-handling.md +144 -0
- package/template/client/.env.example +5 -0
- package/template/client/README.md +36 -0
- package/template/client/components.json +23 -0
- package/template/client/eslint.config.mjs +18 -0
- package/template/client/next.config.ts +34 -0
- package/template/client/package.json +44 -0
- package/template/client/postcss.config.mjs +7 -0
- package/template/client/src/app/(auth)/layout.tsx +18 -0
- package/template/client/src/app/(auth)/login/page.tsx +13 -0
- package/template/client/src/app/(auth)/register/page.tsx +13 -0
- package/template/client/src/app/(main)/dashboard/page.tsx +22 -0
- package/template/client/src/app/(main)/layout.tsx +11 -0
- package/template/client/src/app/error.tsx +27 -0
- package/template/client/src/app/favicon.ico +0 -0
- package/template/client/src/app/globals.css +145 -0
- package/template/client/src/app/layout.tsx +36 -0
- package/template/client/src/app/loading.tsx +11 -0
- package/template/client/src/app/not-found.tsx +23 -0
- package/template/client/src/app/page.tsx +45 -0
- package/template/client/src/app/providers.tsx +43 -0
- package/template/client/src/components/common/ConfirmDialog.tsx +56 -0
- package/template/client/src/components/common/EmptyState.tsx +31 -0
- package/template/client/src/components/common/LoadingSpinner.tsx +30 -0
- package/template/client/src/components/common/Pagination.tsx +55 -0
- package/template/client/src/components/layout/Footer.tsx +17 -0
- package/template/client/src/components/layout/Header.tsx +173 -0
- package/template/client/src/components/layout/MainLayout.tsx +18 -0
- package/template/client/src/components/ui/alert-dialog.tsx +196 -0
- package/template/client/src/components/ui/badge.tsx +48 -0
- package/template/client/src/components/ui/button.tsx +64 -0
- package/template/client/src/components/ui/card.tsx +92 -0
- package/template/client/src/components/ui/input.tsx +21 -0
- package/template/client/src/components/ui/label.tsx +24 -0
- package/template/client/src/components/ui/select.tsx +190 -0
- package/template/client/src/components/ui/skeleton.tsx +13 -0
- package/template/client/src/components/ui/table.tsx +116 -0
- package/template/client/src/features/auth/components/AuthInitializer.tsx +55 -0
- package/template/client/src/features/auth/components/LoginForm.tsx +107 -0
- package/template/client/src/features/auth/components/RegisterForm.tsx +178 -0
- package/template/client/src/features/auth/hooks/useAuth.ts +84 -0
- package/template/client/src/features/auth/services/auth.service.ts +52 -0
- package/template/client/src/features/auth/store/authSlice.ts +38 -0
- package/template/client/src/features/auth/types/auth.types.ts +32 -0
- package/template/client/src/hooks/useDebounce.ts +14 -0
- package/template/client/src/hooks/useLocalStorage.ts +55 -0
- package/template/client/src/hooks/useMediaQuery.ts +27 -0
- package/template/client/src/lib/api/api.types.ts +34 -0
- package/template/client/src/lib/api/axios.config.ts +98 -0
- package/template/client/src/lib/constants/api-endpoints.ts +18 -0
- package/template/client/src/lib/constants/app.constants.ts +12 -0
- package/template/client/src/lib/constants/routes.ts +9 -0
- package/template/client/src/lib/utils/error.ts +32 -0
- package/template/client/src/lib/utils/format.ts +37 -0
- package/template/client/src/lib/utils/security.ts +34 -0
- package/template/client/src/lib/utils.ts +6 -0
- package/template/client/src/middleware.ts +57 -0
- package/template/client/src/store/hooks.ts +7 -0
- package/template/client/src/store/index.ts +12 -0
- package/template/client/src/types/index.ts +3 -0
- package/template/client/tsconfig.json +34 -0
- package/template/gitignore +34 -0
- package/template/server/.dockerignore +66 -0
- package/template/server/.env.example +96 -69
- package/template/server/.env.production.example +90 -0
- package/template/server/Dockerfile +94 -0
- package/template/server/docker-compose.yml +82 -111
- package/template/server/docs/logging.md +62 -0
- package/template/server/eslint.config.mjs +17 -0
- package/template/server/package.json +68 -81
- package/template/server/phpmyadmin-config.php +26 -0
- package/template/server/postman_collection.json +666 -0
- package/template/server/prisma/schema.prisma +77 -93
- package/template/server/prisma/seed.ts +46 -142
- package/template/server/scripts/flush-redis.ts +41 -0
- package/template/server/src/app.ts +243 -71
- package/template/server/src/config/env.ts +67 -94
- package/template/server/src/libs/auth.ts +88 -0
- package/template/server/src/libs/cleanup.ts +35 -0
- package/template/server/src/libs/cookies.ts +46 -0
- package/template/server/src/libs/logger.ts +33 -60
- package/template/server/src/libs/monitoring.ts +205 -0
- package/template/server/src/libs/password.ts +38 -0
- package/template/server/src/libs/prisma.ts +68 -0
- package/template/server/src/libs/redis.ts +60 -79
- package/template/server/src/libs/requestLogger.ts +66 -0
- package/template/server/src/libs/storage/file-storage.service.ts +211 -0
- package/template/server/src/libs/storage/file-validator.ts +97 -0
- package/template/server/src/libs/storage/filename-sanitizer.ts +71 -0
- package/template/server/src/libs/storage/image-optimizer.service.ts +144 -0
- package/template/server/src/modules/auth/__tests__/auth.service.test.ts +365 -0
- package/template/server/src/modules/auth/auth.controller.ts +90 -141
- package/template/server/src/modules/auth/auth.repo.ts +120 -218
- package/template/server/src/modules/auth/auth.routes.ts +96 -83
- package/template/server/src/modules/auth/auth.schemas.ts +35 -137
- package/template/server/src/modules/auth/auth.service.ts +286 -329
- package/template/server/src/modules/auth/session.repo.ts +110 -0
- package/template/server/src/modules/users/users.controller.ts +120 -0
- package/template/server/src/modules/users/users.repo.ts +77 -0
- package/template/server/src/modules/users/users.routes.ts +89 -0
- package/template/server/src/modules/users/users.schemas.ts +21 -0
- package/template/server/src/modules/users/users.service.ts +169 -0
- package/template/server/src/server.ts +58 -139
- package/template/server/src/shared/errors/AppError.ts +21 -0
- package/template/server/src/shared/errors/errors.ts +43 -0
- package/template/server/src/shared/responses/paginatedResponse.ts +38 -0
- package/template/server/src/shared/responses/successResponse.ts +17 -0
- package/template/server/src/shared/schemas/pagination.schema.ts +12 -0
- package/template/server/src/shared/types/index.ts +26 -0
- package/template/server/src/test/setup.ts +74 -38
- package/template/server/tsconfig.json +27 -89
- package/template/server/uploads/avatars/.gitkeep +1 -0
- package/template/server/vitest.config.ts +43 -98
- package/template/.agent/rules/client/01-project-structure.md +0 -326
- package/template/.agent/rules/client/02-component-patterns.md +0 -249
- package/template/.agent/rules/client/03-typescript-rules.md +0 -226
- package/template/.agent/rules/client/04-state-management.md +0 -474
- package/template/.agent/rules/client/05-api-integration.md +0 -129
- package/template/.agent/rules/client/06-forms-validation.md +0 -129
- package/template/.agent/rules/client/07-common-patterns.md +0 -150
- package/template/.agent/rules/client/08-color-system.md +0 -93
- package/template/.agent/rules/client/09-security-rules.md +0 -97
- package/template/.agent/rules/client/10-testing-strategy.md +0 -370
- package/template/.agent/rules/global/ai-edit-safety.md +0 -38
- package/template/.agent/rules/server/01-db-and-migrations.md +0 -242
- package/template/.agent/rules/server/02-general-rules.md +0 -111
- package/template/.agent/rules/server/03-migrations.md +0 -20
- package/template/.agent/rules/server/04-pagination.md +0 -130
- package/template/.agent/rules/server/05-project-conventions.md +0 -71
- package/template/.agent/rules/server/06-response-handling.md +0 -173
- package/template/.agent/rules/server/07-testing-strategy.md +0 -506
- package/template/.agent/rules/server/08-observability.md +0 -180
- package/template/.agent/rules/server/10-background-jobs-v2.md +0 -185
- package/template/.agent/rules/server/11-rate-limiting-v2.md +0 -210
- package/template/.agent/rules/server/12-performance-optimization.md +0 -567
- package/template/.claude/rules/client-01-project-structure.md +0 -327
- package/template/.claude/rules/client-02-component-patterns.md +0 -250
- package/template/.claude/rules/client-03-typescript-rules.md +0 -227
- package/template/.claude/rules/client-04-state-management.md +0 -475
- package/template/.claude/rules/client-05-api-integration.md +0 -130
- package/template/.claude/rules/client-06-forms-validation.md +0 -130
- package/template/.claude/rules/client-07-common-patterns.md +0 -151
- package/template/.claude/rules/client-08-color-system.md +0 -94
- package/template/.claude/rules/client-09-security-rules.md +0 -98
- package/template/.claude/rules/client-10-testing-strategy.md +0 -371
- package/template/.claude/rules/global-ai-edit-safety.md +0 -39
- package/template/.claude/rules/server-01-db-and-migrations.md +0 -243
- package/template/.claude/rules/server-02-general-rules.md +0 -112
- package/template/.claude/rules/server-03-migrations.md +0 -21
- package/template/.claude/rules/server-04-pagination.md +0 -131
- package/template/.claude/rules/server-05-project-conventions.md +0 -72
- package/template/.claude/rules/server-06-response-handling.md +0 -174
- package/template/.claude/rules/server-07-testing-strategy.md +0 -507
- package/template/.claude/rules/server-08-observability.md +0 -181
- package/template/.claude/rules/server-10-background-jobs-v2.md +0 -186
- package/template/.claude/rules/server-11-rate-limiting-v2.md +0 -211
- package/template/.claude/rules/server-12-performance-optimization.md +0 -568
- package/template/.cursor/rules/client-01-project-structure.mdc +0 -327
- package/template/.cursor/rules/client-02-component-patterns.mdc +0 -250
- package/template/.cursor/rules/client-03-typescript-rules.mdc +0 -227
- package/template/.cursor/rules/client-04-state-management.mdc +0 -475
- package/template/.cursor/rules/client-05-api-integration.mdc +0 -130
- package/template/.cursor/rules/client-06-forms-validation.mdc +0 -130
- package/template/.cursor/rules/client-07-common-patterns.mdc +0 -151
- package/template/.cursor/rules/client-08-color-system.mdc +0 -94
- package/template/.cursor/rules/client-09-security-rules.mdc +0 -98
- package/template/.cursor/rules/client-10-testing-strategy.mdc +0 -371
- package/template/.cursor/rules/global-ai-edit-safety.mdc +0 -39
- package/template/.cursor/rules/server-01-db-and-migrations.mdc +0 -243
- package/template/.cursor/rules/server-02-general-rules.mdc +0 -112
- package/template/.cursor/rules/server-03-migrations.mdc +0 -21
- package/template/.cursor/rules/server-04-pagination.mdc +0 -131
- package/template/.cursor/rules/server-05-project-conventions.mdc +0 -72
- package/template/.cursor/rules/server-06-response-handling.mdc +0 -174
- package/template/.cursor/rules/server-07-testing-strategy.mdc +0 -507
- package/template/.cursor/rules/server-08-observability.mdc +0 -181
- package/template/.cursor/rules/server-09-api-documentation-v2.mdc +0 -169
- package/template/.cursor/rules/server-10-background-jobs-v2.mdc +0 -186
- package/template/.cursor/rules/server-11-rate-limiting-v2.mdc +0 -211
- package/template/.cursor/rules/server-12-performance-optimization.mdc +0 -568
- package/template/CLAUDE.md +0 -207
- package/template/server/.tsc-aliasrc.json +0 -13
- package/template/server/IMPORT_FIX_CHECKLIST.md +0 -98
- package/template/server/IMPORT_FIX_COMPLETE.md +0 -89
- package/template/server/README.md +0 -183
- package/template/server/REMAINING_IMPORT_FIXES.md +0 -150
- package/template/server/SECURITY.md +0 -190
- package/template/server/Tigra-API.postman_collection.json +0 -733
- package/template/server/biome.json +0 -42
- package/template/server/scripts/fix-all-imports.ps1 +0 -52
- package/template/server/scripts/fix-imports-reference.ps1 +0 -16
- package/template/server/scripts/fix-imports.mjs +0 -55
- package/template/server/scripts/setup-env.js +0 -50
- package/template/server/scripts/wait-for-db.js +0 -60
- package/template/server/src/hooks/request-timing.hook.ts +0 -26
- package/template/server/src/libs/auth/authenticate.middleware.ts +0 -22
- package/template/server/src/libs/auth/rbac.middleware.test.ts +0 -134
- package/template/server/src/libs/auth/rbac.middleware.ts +0 -147
- package/template/server/src/libs/db.ts +0 -76
- package/template/server/src/libs/error-handler.ts +0 -89
- package/template/server/src/libs/queue.ts +0 -79
- package/template/server/src/modules/admin/admin.controller.ts +0 -122
- package/template/server/src/modules/admin/admin.routes.ts +0 -62
- package/template/server/src/modules/admin/admin.schemas.ts +0 -35
- package/template/server/src/modules/admin/admin.service.ts +0 -167
- package/template/server/src/modules/auth/auth.integration.test.ts +0 -150
- package/template/server/src/modules/auth/auth.service.test.ts +0 -119
- package/template/server/src/modules/auth/auth.types.ts +0 -97
- package/template/server/src/modules/resources/resources.controller.ts +0 -218
- package/template/server/src/modules/resources/resources.repo.ts +0 -253
- package/template/server/src/modules/resources/resources.routes.ts +0 -116
- package/template/server/src/modules/resources/resources.schemas.ts +0 -146
- package/template/server/src/modules/resources/resources.service.ts +0 -218
- package/template/server/src/modules/resources/resources.types.ts +0 -73
- package/template/server/src/plugins/rate-limit.plugin.ts +0 -21
- package/template/server/src/plugins/security.plugin.ts +0 -21
- package/template/server/src/routes/health.routes.ts +0 -31
- package/template/server/src/types/fastify.d.ts +0 -36
- package/template/server/src/utils/errors.ts +0 -108
- package/template/server/src/utils/pagination.ts +0 -120
- package/template/server/src/utils/response.ts +0 -110
- package/template/server/src/workers/file.worker.ts +0 -106
- package/template/server/tsconfig.build.json +0 -30
- package/template/server/tsconfig.test.json +0 -22
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2017",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./src/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"next-env.d.ts",
|
|
27
|
+
"**/*.ts",
|
|
28
|
+
"**/*.tsx",
|
|
29
|
+
".next/types/**/*.ts",
|
|
30
|
+
".next/dev/types/**/*.ts",
|
|
31
|
+
"**/*.mts"
|
|
32
|
+
],
|
|
33
|
+
"exclude": ["node_modules"]
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build output
|
|
5
|
+
dist/
|
|
6
|
+
.next/
|
|
7
|
+
out/
|
|
8
|
+
|
|
9
|
+
# Environment files
|
|
10
|
+
.env
|
|
11
|
+
.env.local
|
|
12
|
+
.env.*.local
|
|
13
|
+
|
|
14
|
+
# OS files
|
|
15
|
+
.DS_Store
|
|
16
|
+
Thumbs.db
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
|
|
22
|
+
# Claude Code local settings
|
|
23
|
+
.claude/settings.local.json
|
|
24
|
+
|
|
25
|
+
# Playwright MCP artifacts
|
|
26
|
+
.playwright-mcp/
|
|
27
|
+
|
|
28
|
+
# Logs
|
|
29
|
+
*.log
|
|
30
|
+
npm-debug.log*
|
|
31
|
+
pnpm-debug.log*
|
|
32
|
+
|
|
33
|
+
# Uploads (local development)
|
|
34
|
+
uploads/
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Node modules (will be installed fresh in Docker)
|
|
2
|
+
node_modules
|
|
3
|
+
npm-debug.log*
|
|
4
|
+
yarn-debug.log*
|
|
5
|
+
yarn-error.log*
|
|
6
|
+
pnpm-debug.log*
|
|
7
|
+
|
|
8
|
+
# Build output (will be built fresh in Docker)
|
|
9
|
+
dist
|
|
10
|
+
build
|
|
11
|
+
*.tsbuildinfo
|
|
12
|
+
|
|
13
|
+
# Environment files (use Docker env vars instead)
|
|
14
|
+
.env
|
|
15
|
+
.env.local
|
|
16
|
+
.env.*.local
|
|
17
|
+
.env.development
|
|
18
|
+
.env.test
|
|
19
|
+
|
|
20
|
+
# Git
|
|
21
|
+
.git
|
|
22
|
+
.gitignore
|
|
23
|
+
.gitattributes
|
|
24
|
+
|
|
25
|
+
# IDE
|
|
26
|
+
.vscode
|
|
27
|
+
.idea
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
*~
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
# Testing
|
|
34
|
+
coverage
|
|
35
|
+
.nyc_output
|
|
36
|
+
**/__tests__
|
|
37
|
+
**/*.test.ts
|
|
38
|
+
**/*.spec.ts
|
|
39
|
+
vitest.config.ts
|
|
40
|
+
|
|
41
|
+
# Documentation
|
|
42
|
+
*.md
|
|
43
|
+
!README.md
|
|
44
|
+
docs
|
|
45
|
+
|
|
46
|
+
# Docker
|
|
47
|
+
Dockerfile
|
|
48
|
+
.dockerignore
|
|
49
|
+
docker-compose.yml
|
|
50
|
+
phpmyadmin-config.php
|
|
51
|
+
|
|
52
|
+
# Postman
|
|
53
|
+
postman_collection.json
|
|
54
|
+
postman/
|
|
55
|
+
|
|
56
|
+
# CI/CD
|
|
57
|
+
.github
|
|
58
|
+
.gitlab-ci.yml
|
|
59
|
+
.circleci
|
|
60
|
+
|
|
61
|
+
# Misc
|
|
62
|
+
.prettierrc
|
|
63
|
+
.eslintrc
|
|
64
|
+
.eslintignore
|
|
65
|
+
.editorconfig
|
|
66
|
+
tsconfig.json
|
|
@@ -1,69 +1,96 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
# ===================================================================
|
|
2
|
+
# APPLICATION CONFIGURATION
|
|
3
|
+
# ===================================================================
|
|
4
|
+
|
|
5
|
+
# Environment: development | production | test
|
|
6
|
+
NODE_ENV=development
|
|
7
|
+
|
|
8
|
+
# Server port (default: 8000)
|
|
9
|
+
PORT=8000
|
|
10
|
+
|
|
11
|
+
# Server host (0.0.0.0 = listen on all interfaces)
|
|
12
|
+
HOST=0.0.0.0
|
|
13
|
+
|
|
14
|
+
# ===================================================================
|
|
15
|
+
# DATABASE CONFIGURATION (MySQL 8.0+)
|
|
16
|
+
# ===================================================================
|
|
17
|
+
|
|
18
|
+
# Database connection string
|
|
19
|
+
# Format: mysql://username:password@host:port/database
|
|
20
|
+
DATABASE_URL="mysql://root:rootpassword@localhost:3306/{{DATABASE_NAME}}"
|
|
21
|
+
|
|
22
|
+
# Connection pool settings (for high-traffic production)
|
|
23
|
+
# Min connections: 2-5 for low traffic, 5-10 for medium, 10-20 for high
|
|
24
|
+
# Max connections: 10 for dev, 20-50 for production (10K-100K users/day)
|
|
25
|
+
DATABASE_POOL_MIN=2
|
|
26
|
+
DATABASE_POOL_MAX=10
|
|
27
|
+
|
|
28
|
+
# ===================================================================
|
|
29
|
+
# REDIS CONFIGURATION
|
|
30
|
+
# ===================================================================
|
|
31
|
+
|
|
32
|
+
# Redis connection URL
|
|
33
|
+
# Format: redis://[:password@]host:port[/database]
|
|
34
|
+
REDIS_URL="redis://localhost:6379"
|
|
35
|
+
|
|
36
|
+
# Max retry attempts for failed Redis operations
|
|
37
|
+
REDIS_MAX_RETRIES=3
|
|
38
|
+
|
|
39
|
+
# Connection timeout in milliseconds
|
|
40
|
+
REDIS_CONNECT_TIMEOUT=10000
|
|
41
|
+
|
|
42
|
+
# ===================================================================
|
|
43
|
+
# JWT AUTHENTICATION
|
|
44
|
+
# ===================================================================
|
|
45
|
+
|
|
46
|
+
# JWT secret key (MUST be at least 32 characters)
|
|
47
|
+
# CRITICAL: Generate a strong random secret for production!
|
|
48
|
+
# Example: openssl rand -base64 48
|
|
49
|
+
JWT_SECRET="{{JWT_SECRET}}"
|
|
50
|
+
|
|
51
|
+
# Access token expiry (short-lived)
|
|
52
|
+
# Format: 1s, 1m, 1h, 1d (default: 15m)
|
|
53
|
+
JWT_ACCESS_EXPIRY="15m"
|
|
54
|
+
|
|
55
|
+
# Refresh token expiry (long-lived)
|
|
56
|
+
# Format: 1s, 1m, 1h, 1d (default: 7d)
|
|
57
|
+
JWT_REFRESH_EXPIRY="7d"
|
|
58
|
+
|
|
59
|
+
# Cookie signing secret (separate from JWT for defense-in-depth)
|
|
60
|
+
# Optional: defaults to JWT_SECRET if not set
|
|
61
|
+
# For production: generate a separate secret: openssl rand -base64 48
|
|
62
|
+
# COOKIE_SECRET="change-this-to-a-different-secret-at-least-32-chars"
|
|
63
|
+
|
|
64
|
+
# ===================================================================
|
|
65
|
+
# CORS (Cross-Origin Resource Sharing)
|
|
66
|
+
# ===================================================================
|
|
67
|
+
|
|
68
|
+
# Allowed origins for CORS
|
|
69
|
+
# Development: Optional (allows all origins for easier local dev)
|
|
70
|
+
# Production: REQUIRED (must be your frontend URL for security)
|
|
71
|
+
# Multiple origins: Separate with commas
|
|
72
|
+
# Examples:
|
|
73
|
+
# Single origin: CORS_ORIGIN="https://myapp.com"
|
|
74
|
+
# Multiple origins: CORS_ORIGIN="https://myapp.com,https://app.myapp.com"
|
|
75
|
+
# Local dev: CORS_ORIGIN="http://localhost:3001"
|
|
76
|
+
# CORS_ORIGIN="http://localhost:3001"
|
|
77
|
+
|
|
78
|
+
# ===================================================================
|
|
79
|
+
# LOGGING
|
|
80
|
+
# ===================================================================
|
|
81
|
+
|
|
82
|
+
# Log level: fatal | error | warn | info | debug | trace
|
|
83
|
+
# Production: info or warn (reduces noise)
|
|
84
|
+
# Development: debug (verbose logging)
|
|
85
|
+
# Staging: info
|
|
86
|
+
LOG_LEVEL=info
|
|
87
|
+
|
|
88
|
+
# ===================================================================
|
|
89
|
+
# ERROR TRACKING (Optional)
|
|
90
|
+
# ===================================================================
|
|
91
|
+
|
|
92
|
+
# Sentry DSN for error tracking and monitoring
|
|
93
|
+
# Get your DSN from: https://sentry.io/settings/projects/
|
|
94
|
+
# Leave empty to disable Sentry
|
|
95
|
+
# Example: SENTRY_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
|
|
96
|
+
# SENTRY_DSN=""
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# ===================================================================
|
|
2
|
+
# PRODUCTION ENVIRONMENT CONFIGURATION
|
|
3
|
+
# ===================================================================
|
|
4
|
+
# This file contains production-optimized settings for high-traffic
|
|
5
|
+
# deployments (10K-100K users/day). Copy to .env and customize.
|
|
6
|
+
# ===================================================================
|
|
7
|
+
|
|
8
|
+
# ===================================================================
|
|
9
|
+
# APPLICATION
|
|
10
|
+
# ===================================================================
|
|
11
|
+
|
|
12
|
+
NODE_ENV=production
|
|
13
|
+
PORT=3000
|
|
14
|
+
HOST=0.0.0.0
|
|
15
|
+
|
|
16
|
+
# ===================================================================
|
|
17
|
+
# DATABASE (MySQL 8.0+)
|
|
18
|
+
# ===================================================================
|
|
19
|
+
|
|
20
|
+
# Production database connection
|
|
21
|
+
# CRITICAL: Use secure credentials, SSL/TLS, and private network
|
|
22
|
+
DATABASE_URL="mysql://prod_user:SECURE_PASSWORD@db.internal:3306/prod_db?ssl=true"
|
|
23
|
+
|
|
24
|
+
# Connection pool for high traffic (10K-100K users/day)
|
|
25
|
+
# Recommended: 20-50 connections for production
|
|
26
|
+
# Monitor and adjust based on load testing results
|
|
27
|
+
DATABASE_POOL_MIN=10
|
|
28
|
+
DATABASE_POOL_MAX=50
|
|
29
|
+
|
|
30
|
+
# ===================================================================
|
|
31
|
+
# REDIS
|
|
32
|
+
# ===================================================================
|
|
33
|
+
|
|
34
|
+
# Production Redis instance
|
|
35
|
+
# CRITICAL: Use authentication and private network
|
|
36
|
+
REDIS_URL="redis://:REDIS_PASSWORD@redis.internal:6379"
|
|
37
|
+
|
|
38
|
+
# Production retry settings
|
|
39
|
+
REDIS_MAX_RETRIES=5
|
|
40
|
+
REDIS_CONNECT_TIMEOUT=5000
|
|
41
|
+
|
|
42
|
+
# ===================================================================
|
|
43
|
+
# JWT AUTHENTICATION
|
|
44
|
+
# ===================================================================
|
|
45
|
+
|
|
46
|
+
# CRITICAL: Generate a cryptographically secure secret
|
|
47
|
+
# Example: openssl rand -base64 48
|
|
48
|
+
JWT_SECRET="YOUR_PRODUCTION_JWT_SECRET_MUST_BE_AT_LEAST_32_CHARS_LONG"
|
|
49
|
+
|
|
50
|
+
# Production token expiry (tighter security)
|
|
51
|
+
JWT_ACCESS_EXPIRY="15m"
|
|
52
|
+
JWT_REFRESH_EXPIRY="7d"
|
|
53
|
+
|
|
54
|
+
# ===================================================================
|
|
55
|
+
# CORS
|
|
56
|
+
# ===================================================================
|
|
57
|
+
|
|
58
|
+
# REQUIRED in production - your frontend domain(s)
|
|
59
|
+
# Multiple origins separated by commas
|
|
60
|
+
CORS_ORIGIN="https://yourdomain.com,https://app.yourdomain.com"
|
|
61
|
+
|
|
62
|
+
# ===================================================================
|
|
63
|
+
# LOGGING
|
|
64
|
+
# ===================================================================
|
|
65
|
+
|
|
66
|
+
# Production: info or warn (reduces log volume)
|
|
67
|
+
# Use warn to reduce costs in high-traffic scenarios
|
|
68
|
+
LOG_LEVEL=info
|
|
69
|
+
|
|
70
|
+
# ===================================================================
|
|
71
|
+
# ERROR TRACKING
|
|
72
|
+
# ===================================================================
|
|
73
|
+
|
|
74
|
+
# Sentry for production error monitoring
|
|
75
|
+
# Get your DSN from: https://sentry.io/settings/projects/
|
|
76
|
+
SENTRY_DSN="https://YOUR_PUBLIC_KEY@o0.ingest.sentry.io/YOUR_PROJECT_ID"
|
|
77
|
+
|
|
78
|
+
# ===================================================================
|
|
79
|
+
# PRODUCTION CHECKLIST
|
|
80
|
+
# ===================================================================
|
|
81
|
+
# [ ] DATABASE_URL uses secure credentials and SSL
|
|
82
|
+
# [ ] JWT_SECRET is a strong random string (48+ chars)
|
|
83
|
+
# [ ] CORS_ORIGIN is set to your exact frontend URL(s)
|
|
84
|
+
# [ ] REDIS_URL uses authentication if Redis is exposed
|
|
85
|
+
# [ ] LOG_LEVEL is set to info or warn
|
|
86
|
+
# [ ] SENTRY_DSN is configured for error tracking
|
|
87
|
+
# [ ] Database connection pool tested under load
|
|
88
|
+
# [ ] All secrets are stored in environment variables, not in code
|
|
89
|
+
# [ ] SSL/TLS certificates are configured
|
|
90
|
+
# [ ] Firewall rules restrict access to database and Redis
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# ===================================================================
|
|
2
|
+
# Multi-stage Dockerfile for Production Deployment
|
|
3
|
+
# Optimized for Coolify, Docker Compose, and Kubernetes
|
|
4
|
+
# ===================================================================
|
|
5
|
+
|
|
6
|
+
# ===================================================================
|
|
7
|
+
# Stage 1: Dependencies (cached layer)
|
|
8
|
+
# ===================================================================
|
|
9
|
+
FROM node:20-alpine AS dependencies
|
|
10
|
+
|
|
11
|
+
# Install production dependencies only
|
|
12
|
+
WORKDIR /app
|
|
13
|
+
|
|
14
|
+
# Copy package files
|
|
15
|
+
COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* ./
|
|
16
|
+
|
|
17
|
+
# Install dependencies (use the lockfile that exists)
|
|
18
|
+
RUN if [ -f pnpm-lock.yaml ]; then \
|
|
19
|
+
npm install -g pnpm && pnpm install --prod --frozen-lockfile; \
|
|
20
|
+
elif [ -f yarn.lock ]; then \
|
|
21
|
+
yarn install --production --frozen-lockfile; \
|
|
22
|
+
else \
|
|
23
|
+
npm ci --omit=dev; \
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
# ===================================================================
|
|
27
|
+
# Stage 2: Build (compile TypeScript)
|
|
28
|
+
# ===================================================================
|
|
29
|
+
FROM node:20-alpine AS builder
|
|
30
|
+
|
|
31
|
+
WORKDIR /app
|
|
32
|
+
|
|
33
|
+
# Copy package files and install ALL dependencies (including dev)
|
|
34
|
+
COPY package.json package-lock.json* pnpm-lock.yaml* yarn.lock* ./
|
|
35
|
+
|
|
36
|
+
RUN if [ -f pnpm-lock.yaml ]; then \
|
|
37
|
+
npm install -g pnpm && pnpm install --frozen-lockfile; \
|
|
38
|
+
elif [ -f yarn.lock ]; then \
|
|
39
|
+
yarn install --frozen-lockfile; \
|
|
40
|
+
else \
|
|
41
|
+
npm ci; \
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Copy source code and Prisma schema
|
|
45
|
+
COPY . .
|
|
46
|
+
|
|
47
|
+
# Generate Prisma Client
|
|
48
|
+
RUN npx prisma generate
|
|
49
|
+
|
|
50
|
+
# Build TypeScript
|
|
51
|
+
RUN npm run build
|
|
52
|
+
|
|
53
|
+
# ===================================================================
|
|
54
|
+
# Stage 3: Production Runtime
|
|
55
|
+
# ===================================================================
|
|
56
|
+
FROM node:20-alpine AS production
|
|
57
|
+
|
|
58
|
+
# Install dumb-init for proper signal handling
|
|
59
|
+
RUN apk add --no-cache dumb-init
|
|
60
|
+
|
|
61
|
+
# Create non-root user for security
|
|
62
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
63
|
+
adduser -S nodejs -u 1001
|
|
64
|
+
|
|
65
|
+
WORKDIR /app
|
|
66
|
+
|
|
67
|
+
# Copy production dependencies from dependencies stage
|
|
68
|
+
COPY --from=dependencies --chown=nodejs:nodejs /app/node_modules ./node_modules
|
|
69
|
+
|
|
70
|
+
# Copy generated Prisma client from builder stage (not present in prod deps)
|
|
71
|
+
COPY --from=builder --chown=nodejs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
|
|
72
|
+
|
|
73
|
+
# Copy built application from builder stage
|
|
74
|
+
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
|
|
75
|
+
COPY --from=builder --chown=nodejs:nodejs /app/package.json ./package.json
|
|
76
|
+
|
|
77
|
+
# Copy Prisma files (needed for migrations)
|
|
78
|
+
COPY --from=builder --chown=nodejs:nodejs /app/prisma ./prisma
|
|
79
|
+
|
|
80
|
+
# Switch to non-root user
|
|
81
|
+
USER nodejs
|
|
82
|
+
|
|
83
|
+
# Expose port (matches default PORT in env.ts; override via PORT env var)
|
|
84
|
+
EXPOSE 8000
|
|
85
|
+
|
|
86
|
+
# Health check for container orchestration
|
|
87
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
88
|
+
CMD node -e "const p=process.env.PORT||8000;require('http').get('http://localhost:'+p+'/api/v1/live',(r)=>{process.exit(r.statusCode===200?0:1)})"
|
|
89
|
+
|
|
90
|
+
# Use dumb-init to handle signals properly
|
|
91
|
+
ENTRYPOINT ["dumb-init", "--"]
|
|
92
|
+
|
|
93
|
+
# Start the application
|
|
94
|
+
CMD ["node", "dist/server.js"]
|
|
@@ -1,111 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
# ==============================================
|
|
84
|
-
# Access at: http://localhost:8081
|
|
85
|
-
redis-commander:
|
|
86
|
-
image: rediscommander/redis-commander:latest
|
|
87
|
-
container_name: {{PROJECT_NAME}}-redis-commander
|
|
88
|
-
restart: unless-stopped
|
|
89
|
-
ports:
|
|
90
|
-
- '8081:8081'
|
|
91
|
-
environment:
|
|
92
|
-
REDIS_HOSTS: local:redis:6379
|
|
93
|
-
networks:
|
|
94
|
-
- {{PROJECT_NAME}}-network
|
|
95
|
-
depends_on:
|
|
96
|
-
- redis
|
|
97
|
-
# ==============================================
|
|
98
|
-
# Named Volumes for Data Persistence
|
|
99
|
-
# ==============================================
|
|
100
|
-
volumes:
|
|
101
|
-
{{PROJECT_NAME}}_mysql_data:
|
|
102
|
-
driver: local
|
|
103
|
-
{{PROJECT_NAME}}_redis_data:
|
|
104
|
-
driver: local
|
|
105
|
-
|
|
106
|
-
# ==============================================
|
|
107
|
-
# Network Configuration
|
|
108
|
-
# ==============================================
|
|
109
|
-
networks:
|
|
110
|
-
{{PROJECT_NAME}}-network:
|
|
111
|
-
driver: bridge
|
|
1
|
+
# WARNING: These credentials are for LOCAL DEVELOPMENT ONLY.
|
|
2
|
+
# Change all passwords and secrets before using in any shared or production environment.
|
|
3
|
+
|
|
4
|
+
name: {{PROJECT_NAME}}
|
|
5
|
+
|
|
6
|
+
services:
|
|
7
|
+
mysql:
|
|
8
|
+
image: mysql:8.0
|
|
9
|
+
container_name: {{PROJECT_NAME}}-mysql
|
|
10
|
+
restart: unless-stopped
|
|
11
|
+
ports:
|
|
12
|
+
- '3306:3306'
|
|
13
|
+
environment:
|
|
14
|
+
MYSQL_ROOT_PASSWORD: rootpassword
|
|
15
|
+
MYSQL_DATABASE: {{DATABASE_NAME}}
|
|
16
|
+
volumes:
|
|
17
|
+
- mysql_data:/var/lib/mysql
|
|
18
|
+
networks:
|
|
19
|
+
- {{PROJECT_NAME}}-network
|
|
20
|
+
healthcheck:
|
|
21
|
+
test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
|
|
22
|
+
interval: 10s
|
|
23
|
+
timeout: 5s
|
|
24
|
+
retries: 5
|
|
25
|
+
|
|
26
|
+
phpmyadmin:
|
|
27
|
+
image: phpmyadmin:latest
|
|
28
|
+
container_name: {{PROJECT_NAME}}-phpmyadmin
|
|
29
|
+
restart: unless-stopped
|
|
30
|
+
ports:
|
|
31
|
+
- '8080:80'
|
|
32
|
+
environment:
|
|
33
|
+
PMA_HOST: mysql
|
|
34
|
+
PMA_PORT: 3306
|
|
35
|
+
MYSQL_ROOT_PASSWORD: rootpassword
|
|
36
|
+
PMA_ARBITRARY: 0
|
|
37
|
+
HIDE_PHP_VERSION: 'true'
|
|
38
|
+
volumes:
|
|
39
|
+
- ./phpmyadmin-config.php:/etc/phpmyadmin/config.user.inc.php
|
|
40
|
+
depends_on:
|
|
41
|
+
mysql:
|
|
42
|
+
condition: service_healthy
|
|
43
|
+
networks:
|
|
44
|
+
- {{PROJECT_NAME}}-network
|
|
45
|
+
|
|
46
|
+
redis:
|
|
47
|
+
image: redis:7-alpine
|
|
48
|
+
container_name: {{PROJECT_NAME}}-redis
|
|
49
|
+
restart: unless-stopped
|
|
50
|
+
ports:
|
|
51
|
+
- '6379:6379'
|
|
52
|
+
volumes:
|
|
53
|
+
- redis_data:/data
|
|
54
|
+
networks:
|
|
55
|
+
- {{PROJECT_NAME}}-network
|
|
56
|
+
healthcheck:
|
|
57
|
+
test: ['CMD', 'redis-cli', 'ping']
|
|
58
|
+
interval: 10s
|
|
59
|
+
timeout: 5s
|
|
60
|
+
retries: 5
|
|
61
|
+
|
|
62
|
+
redis-commander:
|
|
63
|
+
image: rediscommander/redis-commander:latest
|
|
64
|
+
container_name: {{PROJECT_NAME}}-redis-commander
|
|
65
|
+
restart: unless-stopped
|
|
66
|
+
ports:
|
|
67
|
+
- '8081:8081'
|
|
68
|
+
environment:
|
|
69
|
+
REDIS_HOSTS: local:redis:6379
|
|
70
|
+
depends_on:
|
|
71
|
+
redis:
|
|
72
|
+
condition: service_healthy
|
|
73
|
+
networks:
|
|
74
|
+
- {{PROJECT_NAME}}-network
|
|
75
|
+
|
|
76
|
+
volumes:
|
|
77
|
+
mysql_data:
|
|
78
|
+
redis_data:
|
|
79
|
+
|
|
80
|
+
networks:
|
|
81
|
+
{{PROJECT_NAME}}-network:
|
|
82
|
+
driver: bridge
|