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,207 +0,0 @@
1
- # Project Rules for Claude
2
-
3
- > This file is automatically loaded by Claude Code at the start of each conversation.
4
- > For detailed rules, see `.claude/rules/` directory.
5
-
6
- ## Safe Editing Rules (CRITICAL)
7
-
8
- - Assume this is a **production project**. No destructive or experimental changes.
9
- - Keep changes **small and focused**.
10
- - Do NOT change existing function signatures, exports, or imports unless explicitly asked.
11
- - Preserve existing behavior for: Auth, Core business flows, Payment flows.
12
- - If introducing a breaking change, **call it out clearly**.
13
- - Add `// TODO:` comments for ambiguous or incomplete sections.
14
- - Do NOT add noisy debug logs.
15
-
16
- ---
17
-
18
- ## Stack Overview
19
-
20
- ### Server (`server/`)
21
- - **Runtime**: Node.js 20+ LTS
22
- - **Framework**: Fastify
23
- - **Language**: TypeScript (strict mode)
24
- - **Database**: MySQL + Prisma ORM
25
- - **Cache/Queue**: Redis + BullMQ
26
- - **Validation**: Zod
27
- - **Testing**: Vitest
28
-
29
- ### Client (`client/`)
30
- - **Framework**: React 18+ with Vite
31
- - **UI Library**: Ant Design
32
- - **State**: Redux Toolkit + React Query
33
- - **Language**: TypeScript (strict mode)
34
- - **Styling**: CSS Modules / Tailwind
35
-
36
- ---
37
-
38
- ## Server Architecture
39
-
40
- ### File Structure
41
- ```
42
- server/src/
43
- ├── app.ts # Fastify instance & plugin registration
44
- ├── server.ts # Server bootstrap (listen call only)
45
- ├── config/ # env, constants
46
- ├── libs/ # Shared: db, redis, logger, auth
47
- ├── plugins/ # Fastify plugins
48
- ├── hooks/ # Fastify hooks
49
- ├── routes/ # Standalone routes (health, etc.)
50
- └── modules/<domain>/ # Domain modules
51
- ├── <domain>.routes.ts
52
- ├── <domain>.controller.ts
53
- ├── <domain>.service.ts
54
- ├── <domain>.repo.ts
55
- ├── <domain>.schemas.ts
56
- └── <domain>.types.ts
57
- ```
58
-
59
- ### Layered Architecture
60
- ```
61
- Routes → Controllers → Services → Repositories → DB
62
- ```
63
-
64
- - **Controllers**: HTTP handlers only, no business logic
65
- - **Services**: Business logic, throw typed `AppError` instances
66
- - **Repositories**: Database queries only
67
-
68
- ### Response Contract (MANDATORY)
69
-
70
- **Success Response:**
71
- ```json
72
- {
73
- "success": true,
74
- "message": "Human readable message",
75
- "data": {}
76
- }
77
- ```
78
-
79
- **Error Response:**
80
- ```json
81
- {
82
- "success": false,
83
- "error": {
84
- "code": "ERROR_CODE",
85
- "message": "Human readable message"
86
- }
87
- }
88
- ```
89
-
90
- - Use `successResponse()` helper in controllers
91
- - Throw typed errors (`BadRequestError`, `NotFoundError`, etc.)
92
- - NEVER expose stack traces or internal errors to clients
93
-
94
- ### Error Types
95
- - `BadRequestError`, `ValidationError`, `UnauthorizedError`
96
- - `ForbiddenError`, `NotFoundError`, `ConflictError`, `InternalError`
97
-
98
- ---
99
-
100
- ## Client Architecture
101
-
102
- ### File Structure
103
- ```
104
- client/src/
105
- ├── app/ # App config (App.tsx, router, providers)
106
- ├── components/
107
- │ ├── layout/ # Header, Footer, Sidebar, MainLayout
108
- │ └── common/ # Shared components
109
- ├── features/<domain>/ # Feature modules
110
- │ ├── components/
111
- │ ├── hooks/
112
- │ ├── pages/
113
- │ ├── services/
114
- │ ├── store/
115
- │ ├── types/
116
- │ └── utils/
117
- ├── hooks/ # Global hooks
118
- ├── lib/
119
- │ ├── api/ # Axios config, API types
120
- │ ├── constants/ # routes, api-endpoints, app.constants
121
- │ └── utils/
122
- ├── store/ # Redux store
123
- ├── types/ # Global types
124
- └── styles/
125
- ```
126
-
127
- ### Naming Conventions
128
- - **Components**: `PascalCase.tsx` (e.g., `ResourceCard.tsx`)
129
- - **Pages**: `PascalCase + Page.tsx` (e.g., `ResourcesPage.tsx`)
130
- - **Hooks**: `use<Name>.ts` (e.g., `useAuth.ts`)
131
- - **Services**: `<domain>.service.ts`
132
- - **Types**: `<domain>.types.ts`
133
-
134
- ### TypeScript Rules
135
- - **NO `any` type** - use `unknown` if needed
136
- - Explicit return types for all functions
137
- - Use `interface` for props/objects, `type` for unions/intersections
138
-
139
- ### API Response Types (must match backend)
140
- ```tsx
141
- interface ApiResponse<T> {
142
- success: boolean;
143
- message: string;
144
- data: T;
145
- }
146
-
147
- interface PaginatedApiResponse<T> {
148
- success: boolean;
149
- message: string;
150
- data: {
151
- items: T[];
152
- pagination: {
153
- page: number;
154
- limit: number;
155
- totalItems: number;
156
- totalPages: number;
157
- hasNextPage: boolean;
158
- hasPreviousPage: boolean;
159
- };
160
- };
161
- }
162
- ```
163
-
164
- ---
165
-
166
- ## Coding Style (Both)
167
-
168
- - Prefer `async/await` over `.then()`
169
- - Prefer named exports (except `app.ts` and React pages)
170
- - Use path aliases: `@/`, `@/libs/`, `@/modules/`, etc.
171
- - Never `console.log` in production code - use the shared `logger`
172
-
173
- ---
174
-
175
- ## Package Manager Detection
176
-
177
- - `pnpm-lock.yaml` exists → use `pnpm`
178
- - `yarn.lock` exists → use `yarn`
179
- - Otherwise → use `npm`
180
-
181
- ---
182
-
183
- ## When Implementing Features
184
-
185
- 1. Summarize what needs to be done
186
- 2. List files to be created/modified
187
- 3. Provide code for each file
188
- 4. Mention any migrations or env variables needed
189
- 5. If unsure, state assumptions clearly
190
-
191
- ---
192
-
193
- ## Detailed Rules
194
-
195
- For comprehensive rules, read the appropriate files in `.claude/rules/`:
196
-
197
- **Server:**
198
- - `server-02-general-rules.md` - Architecture & code style
199
- - `server-05-project-conventions.md` - File structure & conventions
200
- - `server-06-response-handling.md` - Error & success responses
201
-
202
- **Client:**
203
- - `client-01-project-structure.md` - File structure & naming
204
- - `client-03-typescript-rules.md` - TypeScript conventions
205
-
206
- **Global:**
207
- - `global-ai-edit-safety.md` - Safe editing practices
@@ -1,13 +0,0 @@
1
- {
2
- "verbose": true,
3
- "resolveFullPaths": true,
4
- "resolveFullExtension": ".js",
5
- "replacers": {
6
- "before": [],
7
- "after": []
8
- },
9
- "fileExtensions": {
10
- "inputGlob": "**/*.js",
11
- "outputCheck": ["js"]
12
- }
13
- }
@@ -1,98 +0,0 @@
1
- # Remaining Import Fixes
2
-
3
- This document lists all remaining files that need @/ imports converted to relative .js imports.
4
-
5
- ## Files Fixed So Far (8/20)
6
- 1. ✅ server.ts
7
- 2. ✅ app.ts
8
- 3. ✅ libs/db.ts
9
- 4. ✅ libs/redis.ts
10
- 5. ✅ libs/queue.ts
11
- 6. ✅ libs/error-handler.ts
12
- 7. ✅ libs/auth/authenticate.middleware.ts
13
-
14
- ## Remaining Files (12)
15
-
16
- ### libs/auth/rbac.middleware.ts
17
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
18
-
19
- ### hooks/request-timing.hook.ts
20
- - `from '@/config/env'` → `from '../config/env.js'`
21
-
22
- ### plugins/security.plugin.ts
23
- - `from '@/config/env'` → `from '../config/env.js'`
24
-
25
- ### plugins/rate-limit.plugin.ts
26
- - `from '@/libs/redis'` → `from '../libs/redis.js'`
27
- - `from '@/config/env'` → `from '../config/env.js'`
28
-
29
- ### routes/health.routes.ts
30
- - `from '@/libs/db'` → `from '../libs/db.js'`
31
- - `from '@/libs/redis'` → `from '../libs/redis.js'`
32
-
33
- ### workers/file.worker.ts
34
- - `from '@/libs/redis'` → `from '../libs/redis.js'`
35
- - `from '@/libs/logger'` → `from '../libs/logger.js'`
36
-
37
- ### types/fastify.d.ts
38
- - `from '@/modules/auth/auth.types'` → `from '../modules/auth/auth.types.js'`
39
- - `from '@/libs/auth/rbac.middleware'` → `from '../libs/auth/rbac.middleware.js'`
40
-
41
- ### modules/auth/auth.controller.ts
42
- - `from '@/utils/response'` → `from '../../utils/response.js'`
43
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
44
- - `from './auth.service'` → `from './auth.service.js'`
45
- - `from './auth.repo'` → `from './auth.repo.js'`
46
- - `from './auth.schemas'` → `from './auth.schemas.js'` (appears twice)
47
-
48
- ### modules/auth/auth.service.ts
49
- - `from '@/config/env'` → `from '../../config/env.js'`
50
- - `from '@/libs/logger'` → `from '../../libs/logger.js'`
51
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
52
- - `from './auth.repo'` → `from './auth.repo.js'`
53
- - `from './auth.types'` → `from './auth.types.js'`
54
- - `from './auth.schemas'` → `from './auth.schemas.js'`
55
-
56
- ### modules/auth/auth.repo.ts
57
- - `from '@/libs/db'` → `from '../../libs/db.js'`
58
- - `from './auth.types'` → `from './auth.types.js'`
59
-
60
- ### modules/auth/auth.service.test.ts
61
- - `from '@/config/env'` → `from '../../config/env.js'`
62
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
63
-
64
- ### modules/admin/admin.controller.ts
65
- - `from '@/utils/response'` → `from '../../utils/response.js'`
66
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
67
- - `from './admin.service'` → `from './admin.service.js'`
68
- - `from './admin.schemas'` → `from './admin.schemas.js'`
69
-
70
- ### modules/admin/admin.service.ts
71
- - `from '@/libs/db'` → `from '../../libs/db.js'`
72
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
73
- - `from '@/libs/logger'` → `from '../../libs/logger.js'`
74
-
75
- ### modules/resources/resources.controller.ts
76
- - `from '@/utils/response'` → `from '../../utils/response.js'`
77
- - `from '@/utils/pagination'` → `from '../../utils/pagination.js'`
78
- - `from './resources.service'` → `from './resources.service.js'`
79
- - `from './resources.schemas'` → `from './resources.schemas.js'` (appears twice)
80
-
81
- ### modules/resources/resources.service.ts
82
- - `from '@/libs/logger'` → `from '../../libs/logger.js'`
83
- - `from '@/utils/errors'` → `from '../../utils/errors.js'`
84
- - `from './resources.repo'` → `from './resources.repo.js'`
85
- - `from './resources.types'` → `from './resources.types.js'`
86
- - `from './resources.schemas'` → `from './resources.schemas.js'`
87
-
88
- ### modules/resources/resources.repo.ts
89
- - `from '@/libs/db'` → `from '../../libs/db.js'`
90
- - `from './resources.types'` → `from './resources.types.js'`
91
- - `from './resources.schemas'` → `from './resources.schemas.js'`
92
-
93
- ## After Fixing All Imports
94
-
95
- 1. Delete `.tsc-aliasrc.json` (no longer needed)
96
- 2. Remove `tsc-alias` from devDependencies in package.json
97
- 3. Test build: `npm run build`
98
- 4. Test run: `npm start`
@@ -1,89 +0,0 @@
1
- # ✅ Import Fix Complete!
2
-
3
- ## Summary
4
-
5
- Successfully converted **ALL 20 FILES** from `@/` path aliases to relative imports with `.js` extensions for ES module compatibility.
6
-
7
- ## Files Fixed (20/20) ✅
8
-
9
- ### Core Files (2)
10
- 1. ✅ src/server.ts
11
- 2. ✅ src/app.ts
12
-
13
- ### Libs (5)
14
- 3. ✅ src/libs/db.ts
15
- 4. ✅ src/libs/redis.ts
16
- 5. ✅ src/libs/queue.ts
17
- 6. ✅ src/libs/error-handler.ts
18
- 7. ✅ src/libs/auth/authenticate.middleware.ts
19
- 8. ✅ src/libs/auth/rbac.middleware.ts
20
-
21
- ### Hooks, Plugins, Routes, Workers, Types (6)
22
- 9. ✅ src/hooks/request-timing.hook.ts
23
- 10. ✅ src/plugins/security.plugin.ts
24
- 11. ✅ src/plugins/rate-limit.plugin.ts
25
- 12. ✅ src/routes/health.routes.ts
26
- 13. ✅ src/workers/file.worker.ts
27
- 14. ✅ src/types/fastify.d.ts
28
-
29
- ### Auth Module (3)
30
- 15. ✅ src/modules/auth/auth.repo.ts
31
- 16. ✅ src/modules/auth/auth.service.ts
32
- 17. ✅ src/modules/auth/auth.controller.ts
33
-
34
- ### Admin Module (2)
35
- 18. ✅ src/modules/admin/admin.service.ts
36
- 19. ✅ src/modules/admin/admin.controller.ts
37
-
38
- ### Resources Module (3)
39
- 20. ✅ src/modules/resources/resources.service.ts
40
- 21. ✅ src/modules/resources/resources.repo.ts
41
- 22. ✅ src/modules/resources/resources.controller.ts
42
-
43
- ## Next Steps
44
-
45
- ### 1. Clean Up (Optional)
46
- ```powershell
47
- # Delete temporary files
48
- rm .tsc-aliasrc.json
49
- rm scripts/fix-imports.mjs
50
- rm scripts/fix-all-imports.ps1
51
- rm IMPORT_FIX_CHECKLIST.md
52
- rm REMAINING_IMPORT_FIXES.md
53
- ```
54
-
55
- ### 2. Test Build
56
- ```powershell
57
- npm run build
58
- ```
59
-
60
- ### 3. Test Run
61
- ```powershell
62
- npm start
63
- ```
64
-
65
- ## What Was Changed
66
-
67
- Every import statement was updated:
68
- - **Before**: `import { something } from '@/path/to/module'`
69
- - **After**: `import { something } from '../../path/to/module.js'`
70
-
71
- All relative imports now include the `.js` extension as required by ES modules in Node.js.
72
-
73
- ## Pattern Used
74
-
75
- - Files in `src/` → `./file.js`
76
- - Files in `src/folder/` → `../file.js`
77
- - Files in `src/folder/subfolder/` → `../../file.js`
78
- - Always add `.js` extension to relative imports
79
-
80
- ## Configuration Changes
81
-
82
- - ✅ Removed `tsc-alias` from build script in `package.json`
83
- - ✅ Removed path aliases from `tsconfig.build.json`
84
-
85
- ## Status
86
-
87
- 🎉 **All imports successfully converted!**
88
-
89
- The project is now ready to build and run with ES modules.
@@ -1,183 +0,0 @@
1
- # {{PROJECT_DISPLAY_NAME}}
2
-
3
- {{PROJECT_DESCRIPTION}}
4
-
5
- ## Features
6
- - JWT Authentication (access + refresh tokens)
7
- - User management with role-based access
8
- - Complete CRUD for resources
9
- - Pagination with filters
10
- - Rate limiting with Redis
11
- - Background job processing (BullMQ)
12
- - Comprehensive error handling
13
- - Request logging and monitoring
14
- - Health checks
15
-
16
- ## Tech Stack
17
- - **Runtime**: Node.js 20+
18
- - **Framework**: Fastify 4
19
- - **Database**: MySQL 8.0 with Prisma ORM
20
- - **Cache/Queue**: Redis + BullMQ
21
- - **Validation**: Zod
22
- - **Authentication**: JWT (jsonwebtoken)
23
- - **Testing**: Vitest + Supertest
24
-
25
- ## Prerequisites
26
- - Node.js 20 or higher
27
- - Docker and Docker Compose
28
- - npm or pnpm
29
-
30
- ## Quick Start
31
-
32
- ```bash
33
- # 1. Install dependencies
34
- npm install
35
-
36
- # 2. Start Docker services (MySQL + Redis)
37
- docker-compose up -d
38
-
39
- # 3. Initialize database (creates .env, waits for DB, runs migrations)
40
- npm run db:init
41
-
42
- # 4. Seed the database
43
- npm run prisma:seed
44
-
45
- # 5. Start development server
46
- npm run dev
47
- ```
48
-
49
- Server will start at http://localhost:3000
50
-
51
- ### Production Installation
52
-
53
- For production deployments, install only production dependencies:
54
-
55
- ```bash
56
- # Install production dependencies only (faster, smaller)
57
- npm install --omit=dev
58
-
59
- # Generate Prisma Client
60
- npx prisma generate
61
-
62
- # Run migrations
63
- npx prisma migrate deploy
64
- ```
65
-
66
- ## API Endpoints
67
-
68
- Once running, you can access:
69
- - Health Check: http://localhost:3000/health
70
- - Auth endpoints: http://localhost:3000/api/v1/auth/*
71
- - Resources endpoints: http://localhost:3000/api/v1/resources/*
72
- - Admin endpoints: http://localhost:3000/api/v1/admin/*
73
-
74
- ## Available Scripts
75
-
76
- ```bash
77
- npm run dev # Start dev server with hot reload
78
- npm run build # Build for production
79
- npm run start # Start production server
80
- npm test # Run tests
81
- npm run test:watch # Run tests in watch mode
82
- npm run test:coverage # Generate coverage report
83
- npm run prisma:generate # Generate Prisma Client
84
- npm run prisma:migrate # Run migrations (dev)
85
- npm run prisma:seed # Seed database
86
- npm run prisma:studio # Open Prisma Studio
87
- ```
88
-
89
- ## Project Structure
90
-
91
- ```
92
- src/
93
- ├── app.ts # Fastify app with plugins
94
- ├── server.ts # Server startup
95
- ├── config/
96
- │ └── env.ts # Environment validation
97
- ├── libs/
98
- │ ├── db.ts # Prisma client
99
- │ ├── redis.ts # Redis connection
100
- │ ├── logger.ts # Pino logger
101
- │ └── queue.ts # BullMQ queues
102
- ├── modules/
103
- │ ├── auth/ # Authentication module
104
- │ │ ├── auth.routes.ts
105
- │ │ ├── auth.controller.ts
106
- │ │ ├── auth.service.ts
107
- │ │ ├── auth.repo.ts
108
- │ │ ├── auth.schemas.ts
109
- │ │ └── auth.types.ts
110
- │ └── resources/ # Resources module
111
- ├── utils/
112
- │ ├── errors.ts # Custom error classes
113
- │ ├── response.ts # Response helpers
114
- │ └── pagination.ts # Pagination helper
115
- └── workers/
116
- └── email.worker.ts # Background email worker
117
- ```
118
-
119
- ## Environment Variables
120
-
121
- Required:
122
- - `DATABASE_URL` - MySQL connection string
123
- - `JWT_SECRET` - JWT signing secret (min 32 chars)
124
- - `REDIS_HOST` - Redis host
125
- - `REDIS_PORT` - Redis port
126
-
127
- See `.env.example` for all available variables.
128
-
129
- ## Testing
130
-
131
- ```bash
132
- npm test # Run all tests
133
- npm run test:coverage # Generate coverage report
134
- ```
135
-
136
- Coverage targets: 70%+ overall
137
-
138
- ## Management Tools
139
-
140
- The project includes built-in web interfaces for managing your data:
141
-
142
- ### Database (phpMyAdmin)
143
- - **URL:** [http://localhost:8080](http://localhost:8080)
144
- - **User:** `{{DATABASE_USER}}` or `root`
145
- - **Password:** `{{DATABASE_PASSWORD}}` or `password` (check `docker-compose.yml`)
146
-
147
- ### Redis (Redis Commander)
148
- - **URL:** [http://localhost:8081](http://localhost:8081)
149
- - **Host:** `local:redis:6379` (default)
150
-
151
- ## Production Deployment
152
-
153
- ### Production Checklist
154
-
155
- - [ ] Set `NODE_ENV=production`
156
- - [ ] Build application: `npm run build`
157
- - [ ] Configure environment variables
158
- - [ ] Configure Nginx reverse proxy
159
- - [ ] Set up SSL certificates (Let's Encrypt)
160
- - [ ] Configure firewall (UFW/iptables)
161
- - [ ] Set up monitoring (Sentry, logging)
162
- - [ ] Configure log rotation
163
- - [ ] Set up automated backups (database + uploads)
164
- - [ ] Configure rate limiting for production
165
- - [ ] Enable CORS for production domains only
166
-
167
- ## Security
168
-
169
- This project follows security best practices and undergoes regular security audits.
170
-
171
- **Security Status**: Production dependencies 100% secure
172
-
173
- For detailed information about:
174
- - Known security considerations
175
- - Security best practices
176
- - Vulnerability reporting
177
- - Audit history
178
-
179
- See **[SECURITY.md](./SECURITY.md)**
180
-
181
- ## License
182
-
183
- MIT