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.
Files changed (243) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +80 -87
  3. package/bin/create-tigra.js +259 -308
  4. package/package.json +49 -41
  5. package/template/_claude/QUICK_REFERENCE.md +193 -0
  6. package/template/_claude/README.md +53 -0
  7. package/template/_claude/commands/create-client.md +881 -0
  8. package/template/_claude/commands/create-server.md +383 -0
  9. package/template/_claude/rules/client/01-project-structure.md +133 -0
  10. package/template/_claude/rules/client/02-components-and-types.md +146 -0
  11. package/template/_claude/rules/client/03-data-and-state.md +156 -0
  12. package/template/_claude/rules/client/04-design-system.md +185 -0
  13. package/template/_claude/rules/client/05-security.md +55 -0
  14. package/template/_claude/rules/client/06-ux-checklist.md +81 -0
  15. package/template/_claude/rules/client/core.md +42 -0
  16. package/template/_claude/rules/global/core.md +77 -0
  17. package/template/_claude/rules/server/core.md +50 -0
  18. package/template/_claude/rules/server/database.md +124 -0
  19. package/template/_claude/rules/server/project-conventions.md +150 -0
  20. package/template/_claude/rules/server/response-handling.md +144 -0
  21. package/template/client/.env.example +5 -0
  22. package/template/client/README.md +36 -0
  23. package/template/client/components.json +23 -0
  24. package/template/client/eslint.config.mjs +18 -0
  25. package/template/client/next.config.ts +34 -0
  26. package/template/client/package.json +44 -0
  27. package/template/client/postcss.config.mjs +7 -0
  28. package/template/client/src/app/(auth)/layout.tsx +18 -0
  29. package/template/client/src/app/(auth)/login/page.tsx +13 -0
  30. package/template/client/src/app/(auth)/register/page.tsx +13 -0
  31. package/template/client/src/app/(main)/dashboard/page.tsx +22 -0
  32. package/template/client/src/app/(main)/layout.tsx +11 -0
  33. package/template/client/src/app/error.tsx +27 -0
  34. package/template/client/src/app/favicon.ico +0 -0
  35. package/template/client/src/app/globals.css +145 -0
  36. package/template/client/src/app/layout.tsx +36 -0
  37. package/template/client/src/app/loading.tsx +11 -0
  38. package/template/client/src/app/not-found.tsx +23 -0
  39. package/template/client/src/app/page.tsx +45 -0
  40. package/template/client/src/app/providers.tsx +43 -0
  41. package/template/client/src/components/common/ConfirmDialog.tsx +56 -0
  42. package/template/client/src/components/common/EmptyState.tsx +31 -0
  43. package/template/client/src/components/common/LoadingSpinner.tsx +30 -0
  44. package/template/client/src/components/common/Pagination.tsx +55 -0
  45. package/template/client/src/components/layout/Footer.tsx +17 -0
  46. package/template/client/src/components/layout/Header.tsx +173 -0
  47. package/template/client/src/components/layout/MainLayout.tsx +18 -0
  48. package/template/client/src/components/ui/alert-dialog.tsx +196 -0
  49. package/template/client/src/components/ui/badge.tsx +48 -0
  50. package/template/client/src/components/ui/button.tsx +64 -0
  51. package/template/client/src/components/ui/card.tsx +92 -0
  52. package/template/client/src/components/ui/input.tsx +21 -0
  53. package/template/client/src/components/ui/label.tsx +24 -0
  54. package/template/client/src/components/ui/select.tsx +190 -0
  55. package/template/client/src/components/ui/skeleton.tsx +13 -0
  56. package/template/client/src/components/ui/table.tsx +116 -0
  57. package/template/client/src/features/auth/components/AuthInitializer.tsx +55 -0
  58. package/template/client/src/features/auth/components/LoginForm.tsx +107 -0
  59. package/template/client/src/features/auth/components/RegisterForm.tsx +178 -0
  60. package/template/client/src/features/auth/hooks/useAuth.ts +84 -0
  61. package/template/client/src/features/auth/services/auth.service.ts +52 -0
  62. package/template/client/src/features/auth/store/authSlice.ts +38 -0
  63. package/template/client/src/features/auth/types/auth.types.ts +32 -0
  64. package/template/client/src/hooks/useDebounce.ts +14 -0
  65. package/template/client/src/hooks/useLocalStorage.ts +55 -0
  66. package/template/client/src/hooks/useMediaQuery.ts +27 -0
  67. package/template/client/src/lib/api/api.types.ts +34 -0
  68. package/template/client/src/lib/api/axios.config.ts +98 -0
  69. package/template/client/src/lib/constants/api-endpoints.ts +18 -0
  70. package/template/client/src/lib/constants/app.constants.ts +12 -0
  71. package/template/client/src/lib/constants/routes.ts +9 -0
  72. package/template/client/src/lib/utils/error.ts +32 -0
  73. package/template/client/src/lib/utils/format.ts +37 -0
  74. package/template/client/src/lib/utils/security.ts +34 -0
  75. package/template/client/src/lib/utils.ts +6 -0
  76. package/template/client/src/middleware.ts +57 -0
  77. package/template/client/src/store/hooks.ts +7 -0
  78. package/template/client/src/store/index.ts +12 -0
  79. package/template/client/src/types/index.ts +3 -0
  80. package/template/client/tsconfig.json +34 -0
  81. package/template/gitignore +34 -0
  82. package/template/server/.dockerignore +66 -0
  83. package/template/server/.env.example +96 -69
  84. package/template/server/.env.production.example +90 -0
  85. package/template/server/Dockerfile +94 -0
  86. package/template/server/docker-compose.yml +82 -111
  87. package/template/server/docs/logging.md +62 -0
  88. package/template/server/eslint.config.mjs +17 -0
  89. package/template/server/package.json +68 -81
  90. package/template/server/phpmyadmin-config.php +26 -0
  91. package/template/server/postman_collection.json +666 -0
  92. package/template/server/prisma/schema.prisma +77 -93
  93. package/template/server/prisma/seed.ts +46 -142
  94. package/template/server/scripts/flush-redis.ts +41 -0
  95. package/template/server/src/app.ts +243 -71
  96. package/template/server/src/config/env.ts +67 -94
  97. package/template/server/src/libs/auth.ts +88 -0
  98. package/template/server/src/libs/cleanup.ts +35 -0
  99. package/template/server/src/libs/cookies.ts +46 -0
  100. package/template/server/src/libs/logger.ts +33 -60
  101. package/template/server/src/libs/monitoring.ts +205 -0
  102. package/template/server/src/libs/password.ts +38 -0
  103. package/template/server/src/libs/prisma.ts +68 -0
  104. package/template/server/src/libs/redis.ts +60 -79
  105. package/template/server/src/libs/requestLogger.ts +66 -0
  106. package/template/server/src/libs/storage/file-storage.service.ts +211 -0
  107. package/template/server/src/libs/storage/file-validator.ts +97 -0
  108. package/template/server/src/libs/storage/filename-sanitizer.ts +71 -0
  109. package/template/server/src/libs/storage/image-optimizer.service.ts +144 -0
  110. package/template/server/src/modules/auth/__tests__/auth.service.test.ts +365 -0
  111. package/template/server/src/modules/auth/auth.controller.ts +90 -141
  112. package/template/server/src/modules/auth/auth.repo.ts +120 -218
  113. package/template/server/src/modules/auth/auth.routes.ts +96 -83
  114. package/template/server/src/modules/auth/auth.schemas.ts +35 -137
  115. package/template/server/src/modules/auth/auth.service.ts +286 -329
  116. package/template/server/src/modules/auth/session.repo.ts +110 -0
  117. package/template/server/src/modules/users/users.controller.ts +120 -0
  118. package/template/server/src/modules/users/users.repo.ts +77 -0
  119. package/template/server/src/modules/users/users.routes.ts +89 -0
  120. package/template/server/src/modules/users/users.schemas.ts +21 -0
  121. package/template/server/src/modules/users/users.service.ts +169 -0
  122. package/template/server/src/server.ts +58 -139
  123. package/template/server/src/shared/errors/AppError.ts +21 -0
  124. package/template/server/src/shared/errors/errors.ts +43 -0
  125. package/template/server/src/shared/responses/paginatedResponse.ts +38 -0
  126. package/template/server/src/shared/responses/successResponse.ts +17 -0
  127. package/template/server/src/shared/schemas/pagination.schema.ts +12 -0
  128. package/template/server/src/shared/types/index.ts +26 -0
  129. package/template/server/src/test/setup.ts +74 -38
  130. package/template/server/tsconfig.json +27 -89
  131. package/template/server/uploads/avatars/.gitkeep +1 -0
  132. package/template/server/vitest.config.ts +43 -98
  133. package/template/.agent/rules/client/01-project-structure.md +0 -326
  134. package/template/.agent/rules/client/02-component-patterns.md +0 -249
  135. package/template/.agent/rules/client/03-typescript-rules.md +0 -226
  136. package/template/.agent/rules/client/04-state-management.md +0 -474
  137. package/template/.agent/rules/client/05-api-integration.md +0 -129
  138. package/template/.agent/rules/client/06-forms-validation.md +0 -129
  139. package/template/.agent/rules/client/07-common-patterns.md +0 -150
  140. package/template/.agent/rules/client/08-color-system.md +0 -93
  141. package/template/.agent/rules/client/09-security-rules.md +0 -97
  142. package/template/.agent/rules/client/10-testing-strategy.md +0 -370
  143. package/template/.agent/rules/global/ai-edit-safety.md +0 -38
  144. package/template/.agent/rules/server/01-db-and-migrations.md +0 -242
  145. package/template/.agent/rules/server/02-general-rules.md +0 -111
  146. package/template/.agent/rules/server/03-migrations.md +0 -20
  147. package/template/.agent/rules/server/04-pagination.md +0 -130
  148. package/template/.agent/rules/server/05-project-conventions.md +0 -71
  149. package/template/.agent/rules/server/06-response-handling.md +0 -173
  150. package/template/.agent/rules/server/07-testing-strategy.md +0 -506
  151. package/template/.agent/rules/server/08-observability.md +0 -180
  152. package/template/.agent/rules/server/10-background-jobs-v2.md +0 -185
  153. package/template/.agent/rules/server/11-rate-limiting-v2.md +0 -210
  154. package/template/.agent/rules/server/12-performance-optimization.md +0 -567
  155. package/template/.claude/rules/client-01-project-structure.md +0 -327
  156. package/template/.claude/rules/client-02-component-patterns.md +0 -250
  157. package/template/.claude/rules/client-03-typescript-rules.md +0 -227
  158. package/template/.claude/rules/client-04-state-management.md +0 -475
  159. package/template/.claude/rules/client-05-api-integration.md +0 -130
  160. package/template/.claude/rules/client-06-forms-validation.md +0 -130
  161. package/template/.claude/rules/client-07-common-patterns.md +0 -151
  162. package/template/.claude/rules/client-08-color-system.md +0 -94
  163. package/template/.claude/rules/client-09-security-rules.md +0 -98
  164. package/template/.claude/rules/client-10-testing-strategy.md +0 -371
  165. package/template/.claude/rules/global-ai-edit-safety.md +0 -39
  166. package/template/.claude/rules/server-01-db-and-migrations.md +0 -243
  167. package/template/.claude/rules/server-02-general-rules.md +0 -112
  168. package/template/.claude/rules/server-03-migrations.md +0 -21
  169. package/template/.claude/rules/server-04-pagination.md +0 -131
  170. package/template/.claude/rules/server-05-project-conventions.md +0 -72
  171. package/template/.claude/rules/server-06-response-handling.md +0 -174
  172. package/template/.claude/rules/server-07-testing-strategy.md +0 -507
  173. package/template/.claude/rules/server-08-observability.md +0 -181
  174. package/template/.claude/rules/server-10-background-jobs-v2.md +0 -186
  175. package/template/.claude/rules/server-11-rate-limiting-v2.md +0 -211
  176. package/template/.claude/rules/server-12-performance-optimization.md +0 -568
  177. package/template/.cursor/rules/client-01-project-structure.mdc +0 -327
  178. package/template/.cursor/rules/client-02-component-patterns.mdc +0 -250
  179. package/template/.cursor/rules/client-03-typescript-rules.mdc +0 -227
  180. package/template/.cursor/rules/client-04-state-management.mdc +0 -475
  181. package/template/.cursor/rules/client-05-api-integration.mdc +0 -130
  182. package/template/.cursor/rules/client-06-forms-validation.mdc +0 -130
  183. package/template/.cursor/rules/client-07-common-patterns.mdc +0 -151
  184. package/template/.cursor/rules/client-08-color-system.mdc +0 -94
  185. package/template/.cursor/rules/client-09-security-rules.mdc +0 -98
  186. package/template/.cursor/rules/client-10-testing-strategy.mdc +0 -371
  187. package/template/.cursor/rules/global-ai-edit-safety.mdc +0 -39
  188. package/template/.cursor/rules/server-01-db-and-migrations.mdc +0 -243
  189. package/template/.cursor/rules/server-02-general-rules.mdc +0 -112
  190. package/template/.cursor/rules/server-03-migrations.mdc +0 -21
  191. package/template/.cursor/rules/server-04-pagination.mdc +0 -131
  192. package/template/.cursor/rules/server-05-project-conventions.mdc +0 -72
  193. package/template/.cursor/rules/server-06-response-handling.mdc +0 -174
  194. package/template/.cursor/rules/server-07-testing-strategy.mdc +0 -507
  195. package/template/.cursor/rules/server-08-observability.mdc +0 -181
  196. package/template/.cursor/rules/server-09-api-documentation-v2.mdc +0 -169
  197. package/template/.cursor/rules/server-10-background-jobs-v2.mdc +0 -186
  198. package/template/.cursor/rules/server-11-rate-limiting-v2.mdc +0 -211
  199. package/template/.cursor/rules/server-12-performance-optimization.mdc +0 -568
  200. package/template/CLAUDE.md +0 -207
  201. package/template/server/.tsc-aliasrc.json +0 -13
  202. package/template/server/IMPORT_FIX_CHECKLIST.md +0 -98
  203. package/template/server/IMPORT_FIX_COMPLETE.md +0 -89
  204. package/template/server/README.md +0 -183
  205. package/template/server/REMAINING_IMPORT_FIXES.md +0 -150
  206. package/template/server/SECURITY.md +0 -190
  207. package/template/server/Tigra-API.postman_collection.json +0 -733
  208. package/template/server/biome.json +0 -42
  209. package/template/server/scripts/fix-all-imports.ps1 +0 -52
  210. package/template/server/scripts/fix-imports-reference.ps1 +0 -16
  211. package/template/server/scripts/fix-imports.mjs +0 -55
  212. package/template/server/scripts/setup-env.js +0 -50
  213. package/template/server/scripts/wait-for-db.js +0 -60
  214. package/template/server/src/hooks/request-timing.hook.ts +0 -26
  215. package/template/server/src/libs/auth/authenticate.middleware.ts +0 -22
  216. package/template/server/src/libs/auth/rbac.middleware.test.ts +0 -134
  217. package/template/server/src/libs/auth/rbac.middleware.ts +0 -147
  218. package/template/server/src/libs/db.ts +0 -76
  219. package/template/server/src/libs/error-handler.ts +0 -89
  220. package/template/server/src/libs/queue.ts +0 -79
  221. package/template/server/src/modules/admin/admin.controller.ts +0 -122
  222. package/template/server/src/modules/admin/admin.routes.ts +0 -62
  223. package/template/server/src/modules/admin/admin.schemas.ts +0 -35
  224. package/template/server/src/modules/admin/admin.service.ts +0 -167
  225. package/template/server/src/modules/auth/auth.integration.test.ts +0 -150
  226. package/template/server/src/modules/auth/auth.service.test.ts +0 -119
  227. package/template/server/src/modules/auth/auth.types.ts +0 -97
  228. package/template/server/src/modules/resources/resources.controller.ts +0 -218
  229. package/template/server/src/modules/resources/resources.repo.ts +0 -253
  230. package/template/server/src/modules/resources/resources.routes.ts +0 -116
  231. package/template/server/src/modules/resources/resources.schemas.ts +0 -146
  232. package/template/server/src/modules/resources/resources.service.ts +0 -218
  233. package/template/server/src/modules/resources/resources.types.ts +0 -73
  234. package/template/server/src/plugins/rate-limit.plugin.ts +0 -21
  235. package/template/server/src/plugins/security.plugin.ts +0 -21
  236. package/template/server/src/routes/health.routes.ts +0 -31
  237. package/template/server/src/types/fastify.d.ts +0 -36
  238. package/template/server/src/utils/errors.ts +0 -108
  239. package/template/server/src/utils/pagination.ts +0 -120
  240. package/template/server/src/utils/response.ts +0 -110
  241. package/template/server/src/workers/file.worker.ts +0 -106
  242. package/template/server/tsconfig.build.json +0 -30
  243. package/template/server/tsconfig.test.json +0 -22
@@ -1,150 +0,0 @@
1
- # Final Import Fix Guide - Remaining 9 Files
2
-
3
- ## Completed So Far (11/20)
4
- 1. ✅ server.ts
5
- 2. ✅ app.ts
6
- 3. ✅ libs/db.ts
7
- 4. ✅ libs/redis.ts
8
- 5. ✅ libs/queue.ts
9
- 6. ✅ libs/error-handler.ts
10
- 7. ✅ libs/auth/authenticate.middleware.ts
11
- 8. ✅ libs/auth/rbac.middleware.ts
12
- 9. ✅ hooks/request-timing.hook.ts
13
- 10. ✅ plugins/security.plugin.ts
14
- 11. ✅ (Continue from here)
15
-
16
- ## Remaining Files - Exact Changes Needed
17
-
18
- ### 1. plugins/rate-limit.plugin.ts
19
- **File location:** `src/plugins/rate-limit.plugin.ts`
20
-
21
- **Changes:**
22
- - Line 3: `from '@/libs/redis'` → `from '../libs/redis.js'`
23
- - Line 4: `from '@/config/env'` → `from '../config/env.js'`
24
-
25
- ### 2. routes/health.routes.ts
26
- **File location:** `src/routes/health.routes.ts`
27
-
28
- **Changes:**
29
- - Line 2: `from '@/libs/db'` → `from '../libs/db.js'`
30
- - Line 3: `from '@/libs/redis'` → `from '../libs/redis.js'`
31
-
32
- ### 3. workers/file.worker.ts
33
- **File location:** `src/workers/file.worker.ts`
34
-
35
- **Changes:**
36
- - Line 11: `from '@/libs/redis'` → `from '../libs/redis.js'`
37
- - Line 12: `from '@/libs/logger'` → `from '../libs/logger.js'`
38
-
39
- ### 4. types/fastify.d.ts
40
- **File location:** `src/types/fastify.d.ts`
41
-
42
- **Changes:**
43
- - `from '@/modules/auth/auth.types'` → `from '../modules/auth/auth.types.js'`
44
- - `from '@/libs/auth/rbac.middleware'` → `from '../libs/auth/rbac.middleware.js'`
45
-
46
- ### 5. modules/auth/auth.controller.ts
47
- **File location:** `src/modules/auth/auth.controller.ts`
48
-
49
- **Changes:**
50
- - `from '@/utils/response'` → `from '../../utils/response.js'`
51
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
52
- - `from './auth.service'` → `from './auth.service.js'`
53
- - `from './auth.repo'` → `from './auth.repo.js'`
54
- - `from './auth.schemas'` → `from './auth.schemas.js'` (appears twice)
55
-
56
- ### 6. modules/auth/auth.service.ts
57
- **File location:** `src/modules/auth/auth.service.ts`
58
-
59
- **Changes:**
60
- - `from '@/config/env'` → `from '../../config/env.js'`
61
- - `from '@/libs/logger'` → `from '../../libs/logger.js'`
62
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
63
- - `from './auth.repo'` → `from './auth.repo.js'`
64
- - `from './auth.types'` → `from './auth.types.js'`
65
- - `from './auth.schemas'` → `from './auth.schemas.js'`
66
-
67
- ### 7. modules/auth/auth.repo.ts
68
- **File location:** `src/modules/auth/auth.repo.ts`
69
-
70
- **Changes:**
71
- - `from '@/libs/db'` → `from '../../libs/db.js'`
72
- - `from './auth.types'` → `from './auth.types.js'`
73
-
74
- ### 8. modules/admin/admin.controller.ts
75
- **File location:** `src/modules/admin/admin.controller.ts`
76
-
77
- **Changes:**
78
- - `from '@/utils/response'` → `from '../../utils/response.js'`
79
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
80
- - `from './admin.service'` → `from './admin.service.js'`
81
- - `from './admin.schemas'` → `from './admin.schemas.js'`
82
-
83
- ### 9. modules/admin/admin.service.ts
84
- **File location:** `src/modules/admin/admin.service.ts`
85
-
86
- **Changes:**
87
- - `from '@/libs/db'` → `from '../../libs/db.js'`
88
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
89
- - `from '@/libs/logger'` → `from '../../libs/logger.js'`
90
-
91
- ### 10. modules/resources/resources.controller.ts
92
- **File location:** `src/modules/resources/resources.controller.ts`
93
-
94
- **Changes:**
95
- - `from '@/utils/response'` → `from '../../utils/response.js'`
96
- - `from '@/utils/pagination'` → `from '../../utils/pagination.js'`
97
- - `from './resources.service'` → `from './resources.service.js'`
98
- - `from './resources.schemas'` → `from './resources.schemas.js'` (appears twice)
99
-
100
- ### 11. modules/resources/resources.service.ts
101
- **File location:** `src/modules/resources/resources.service.ts`
102
-
103
- **Changes:**
104
- - `from '@/libs/logger'` → `from '../../libs/logger.js'`
105
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
106
- - `from './resources.repo'` → `from './resources.repo.js'`
107
- - `from './resources.types'` → `from './resources.types.js'`
108
- - `from './resources.schemas'` → `from './resources.schemas.js'`
109
-
110
- ### 12. modules/resources/resources.repo.ts
111
- **File location:** `src/modules/resources/resources.repo.ts`
112
-
113
- **Changes:**
114
- - `from '@/libs/db'` → `from '../../libs/db.js'`
115
- - `from './resources.types'` → `from './resources.types.js'`
116
- - `from './resources.schemas'` → `from './resources.schemas.js'`
117
-
118
- ## Pattern Summary
119
-
120
- ### For files in `src/` (depth 0):
121
- - `@/config/*` → `./config/*.js`
122
- - `@/libs/*` → `./libs/*.js`
123
- - `@/modules/*` → `./modules/*.js`
124
-
125
- ### For files in `src/subfolder/` (depth 1):
126
- - `@/config/*` → `../config/*.js`
127
- - `@/libs/*` → `../libs/*.js`
128
- - `@/modules/*` → `../modules/*.js`
129
- - `@/utils/*` → `../utils/*.js`
130
-
131
- ### For files in `src/subfolder/subfolder/` (depth 2):
132
- - `@/config/*` → `../../config/*.js`
133
- - `@/libs/*` → `../../libs/*.js`
134
- - `@/utils/*` → `../../utils/*.js`
135
- - `./file` → `./file.js`
136
-
137
- ## After Completing All Fixes
138
-
139
- 1. Delete `.tsc-aliasrc.json`
140
- 2. Run `npm run build` to test compilation
141
- 3. Fix any remaining errors
142
- 4. Run `npm start` to test execution
143
-
144
- ## Quick Test Command
145
- ```powershell
146
- # From template/server directory
147
- npm run build
148
- ```
149
-
150
- If build succeeds, all imports are correctly fixed!
@@ -1,190 +0,0 @@
1
- # Security Considerations
2
-
3
- ## Overview
4
-
5
- This document outlines known security considerations for this project. We take security seriously and regularly audit our dependencies for vulnerabilities.
6
-
7
- **Last Security Audit**: January 10, 2026
8
- **Next Scheduled Audit**: February 10, 2026
9
-
10
- ---
11
-
12
- ## Current Security Status
13
-
14
- **Production Dependencies**: 100% Secure (0 vulnerabilities)
15
- **Development Dependencies**: 100% Secure (0 vulnerabilities)
16
- **Overall Security Score**: 100/100
17
-
18
- ---
19
-
20
- ## Known Issues
21
-
22
- **None** - All dependencies are currently secure with no known vulnerabilities.
23
-
24
- ---
25
-
26
- ## Security Best Practices
27
-
28
- ### Dependency Management
29
-
30
- 1. **Monthly Security Audits**
31
- ```bash
32
- npm audit
33
- npm outdated
34
- ```
35
-
36
- 2. **Automated Monitoring**
37
- - Enable GitHub Dependabot
38
- - Subscribe to security advisories
39
- - Monitor npm security feeds
40
-
41
- 3. **Update Strategy**
42
- - Patch versions: Update immediately
43
- - Minor versions: Update monthly
44
- - Major versions: Review and test before updating
45
-
46
- ### Environment Variables
47
-
48
- 1. **Never Commit Secrets**
49
- - Use `.env` files (gitignored)
50
- - Use environment-specific configurations
51
- - Rotate secrets regularly
52
-
53
- 2. **Required Environment Variables**
54
- ```bash
55
- # See .env.example for full list
56
- DATABASE_URL=mysql://...
57
- JWT_SECRET=<minimum-32-characters>
58
- REDIS_HOST=localhost
59
- ```
60
-
61
- 3. **Validation**
62
- - All environment variables are validated at startup
63
- - See `src/config/env.ts` for schema
64
-
65
- ### Authentication & Authorization
66
-
67
- 1. **JWT Security**
68
- - Tokens include issuer validation
69
- - Access tokens expire in 15 minutes
70
- - Refresh tokens expire in 7 days
71
- - Secure secret (minimum 32 characters)
72
-
73
- 2. **Password Security**
74
- - bcrypt with 10 rounds
75
- - Minimum password requirements enforced
76
- - No password storage in logs
77
-
78
- 3. **Role-Based Access Control (RBAC)**
79
- - Implemented via middleware
80
- - Three roles: USER, ORGANIZATION, ADMIN
81
- - Route-level permission checks
82
-
83
- ### API Security
84
-
85
- 1. **Rate Limiting**
86
- - Global: 100 requests per 15 minutes
87
- - Login: 5 requests per 15 minutes
88
- - Configurable per route
89
-
90
- 2. **Input Validation**
91
- - All inputs validated with Zod schemas
92
- - Type-safe validation
93
- - Automatic error responses
94
-
95
- 3. **Security Headers**
96
- - Helmet.js for security headers
97
- - CORS properly configured
98
- - CSP enabled in production
99
-
100
- ### Database Security
101
-
102
- 1. **SQL Injection Prevention**
103
- - Prisma ORM (parameterized queries)
104
- - No raw SQL with user input
105
- - Type-safe database access
106
-
107
- 2. **Connection Security**
108
- - Encrypted connections (SSL/TLS)
109
- - Connection pooling
110
- - Credential rotation
111
-
112
- ### Monitoring & Logging
113
-
114
- 1. **Structured Logging**
115
- - Pino for high-performance logging
116
- - Sensitive data redaction
117
- - Request ID tracking
118
-
119
- 2. **Error Handling**
120
- - No stack traces in production responses
121
- - Internal errors logged securely
122
- - User-friendly error messages
123
-
124
- ---
125
-
126
- ## Reporting Security Issues
127
-
128
- If you discover a security vulnerability, please follow responsible disclosure:
129
-
130
- 1. **Do NOT** open a public GitHub issue
131
- 2. Email security concerns to: [itorn9777@gmail.com]
132
- 3. Include:
133
- - Description of the vulnerability
134
- - Steps to reproduce
135
- - Potential impact
136
- - Suggested fix (if any)
137
-
138
- We will respond within 48 hours and work with you to address the issue.
139
-
140
- ---
141
-
142
- ## Security Audit History
143
-
144
- ### January 10, 2026
145
- - **Action**: Comprehensive dependency update
146
- - **Vulnerabilities Fixed**: 8 out of 8 (100%)
147
- - **Status**: All dependencies 100% secure
148
- - **Remaining**: None
149
- - **Next Review**: February 10, 2026
150
-
151
- ### Previous Audits
152
- - Initial security setup and configuration
153
-
154
- ---
155
-
156
- ## Compliance & Standards
157
-
158
- This project follows security best practices including:
159
-
160
- - OWASP Top 10 guidelines
161
- - Secure coding standards
162
- - Regular dependency audits
163
- - Input validation and sanitization
164
- - Secure authentication and authorization
165
- - Encrypted data transmission
166
- - Comprehensive logging and monitoring
167
-
168
- ---
169
-
170
- ## Additional Resources
171
-
172
- **Security Tools:**
173
- - npm audit: Built-in vulnerability scanner
174
- - Snyk: https://snyk.io/
175
- - GitHub Dependabot: Automated dependency updates
176
-
177
- **Security Guides:**
178
- - OWASP: https://owasp.org/
179
- - Node.js Security Best Practices: https://nodejs.org/en/docs/guides/security/
180
- - Fastify Security: https://www.fastify.io/docs/latest/Guides/Security/
181
-
182
- **Monitoring:**
183
- - npm Security Advisories: https://github.com/advisories
184
- - Node.js Security Releases: https://nodejs.org/en/blog/vulnerability/
185
-
186
- ---
187
-
188
- **Last Updated**: January 10, 2026
189
- **Maintained By**: Development Team
190
- **Review Schedule**: Monthly