nodejs-quickstart-structure 1.18.1 → 1.19.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 (235) hide show
  1. package/CHANGELOG.md +309 -294
  2. package/LICENSE +15 -15
  3. package/README.md +2 -1
  4. package/lib/generator.js +139 -139
  5. package/lib/modules/app-setup.js +401 -401
  6. package/lib/modules/caching-setup.js +76 -73
  7. package/lib/modules/config-files.js +151 -151
  8. package/lib/modules/database-setup.js +116 -116
  9. package/lib/modules/kafka-setup.js +249 -191
  10. package/lib/modules/project-setup.js +32 -31
  11. package/lib/prompts.js +100 -100
  12. package/package.json +78 -67
  13. package/templates/clean-architecture/js/src/domain/models/User.js +9 -9
  14. package/templates/clean-architecture/js/src/errors/ApiError.js +14 -14
  15. package/templates/clean-architecture/js/src/errors/BadRequestError.js +11 -10
  16. package/templates/clean-architecture/js/src/errors/BadRequestError.spec.js.ejs +22 -21
  17. package/templates/clean-architecture/js/src/errors/NotFoundError.js +11 -10
  18. package/templates/clean-architecture/js/src/errors/NotFoundError.spec.js.ejs +22 -21
  19. package/templates/clean-architecture/js/src/index.js.ejs +55 -55
  20. package/templates/clean-architecture/js/src/infrastructure/config/env.js.ejs +47 -47
  21. package/templates/clean-architecture/js/src/infrastructure/log/logger.js +36 -36
  22. package/templates/clean-architecture/js/src/infrastructure/log/logger.spec.js.ejs +63 -63
  23. package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.js.ejs +69 -39
  24. package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.spec.js.ejs +142 -81
  25. package/templates/clean-architecture/js/src/infrastructure/webserver/middleware/errorMiddleware.js +30 -30
  26. package/templates/clean-architecture/js/src/infrastructure/webserver/server.js.ejs +89 -89
  27. package/templates/clean-architecture/js/src/infrastructure/webserver/swagger.js.ejs +6 -6
  28. package/templates/clean-architecture/js/src/interfaces/controllers/userController.js.ejs +156 -75
  29. package/templates/clean-architecture/js/src/interfaces/controllers/userController.spec.js.ejs +234 -138
  30. package/templates/clean-architecture/js/src/interfaces/graphql/context.js.ejs +13 -13
  31. package/templates/clean-architecture/js/src/interfaces/graphql/context.spec.js.ejs +31 -31
  32. package/templates/clean-architecture/js/src/interfaces/graphql/index.js.ejs +5 -5
  33. package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/index.js.ejs +6 -6
  34. package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.js.ejs +27 -21
  35. package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.spec.js.ejs +66 -49
  36. package/templates/clean-architecture/js/src/interfaces/graphql/typeDefs/index.js.ejs +6 -6
  37. package/templates/clean-architecture/js/src/interfaces/graphql/typeDefs/user.types.js.ejs +19 -17
  38. package/templates/clean-architecture/js/src/interfaces/routes/api.js +12 -10
  39. package/templates/clean-architecture/js/src/interfaces/routes/api.spec.js.ejs +38 -38
  40. package/templates/clean-architecture/js/src/usecases/CreateUser.js +14 -14
  41. package/templates/clean-architecture/js/src/usecases/CreateUser.spec.js.ejs +51 -51
  42. package/templates/clean-architecture/js/src/usecases/DeleteUser.js +11 -0
  43. package/templates/clean-architecture/js/src/usecases/DeleteUser.spec.js.ejs +47 -0
  44. package/templates/clean-architecture/js/src/usecases/GetAllUsers.js +12 -12
  45. package/templates/clean-architecture/js/src/usecases/GetAllUsers.spec.js.ejs +61 -61
  46. package/templates/clean-architecture/js/src/usecases/UpdateUser.js +11 -0
  47. package/templates/clean-architecture/js/src/usecases/UpdateUser.spec.js.ejs +48 -0
  48. package/templates/clean-architecture/js/src/utils/errorMessages.js +14 -0
  49. package/templates/clean-architecture/js/src/utils/httpCodes.js +9 -9
  50. package/templates/clean-architecture/ts/src/config/env.ts.ejs +46 -46
  51. package/templates/clean-architecture/ts/src/config/swagger.ts.ejs +6 -6
  52. package/templates/clean-architecture/ts/src/domain/user.ts +7 -7
  53. package/templates/clean-architecture/ts/src/errors/ApiError.ts +15 -15
  54. package/templates/clean-architecture/ts/src/errors/BadRequestError.spec.ts.ejs +22 -21
  55. package/templates/clean-architecture/ts/src/errors/BadRequestError.ts +9 -8
  56. package/templates/clean-architecture/ts/src/errors/NotFoundError.spec.ts.ejs +22 -21
  57. package/templates/clean-architecture/ts/src/errors/NotFoundError.ts +9 -8
  58. package/templates/clean-architecture/ts/src/index.ts.ejs +139 -139
  59. package/templates/clean-architecture/ts/src/infrastructure/log/logger.spec.ts.ejs +63 -63
  60. package/templates/clean-architecture/ts/src/infrastructure/log/logger.ts +36 -36
  61. package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.spec.ts.ejs +175 -85
  62. package/templates/clean-architecture/ts/src/infrastructure/repositories/userRepository.ts.ejs +74 -0
  63. package/templates/clean-architecture/ts/src/interfaces/controllers/userController.spec.ts.ejs +331 -185
  64. package/templates/clean-architecture/ts/src/interfaces/controllers/userController.ts.ejs +173 -84
  65. package/templates/clean-architecture/ts/src/interfaces/graphql/context.spec.ts.ejs +32 -32
  66. package/templates/clean-architecture/ts/src/interfaces/graphql/context.ts.ejs +17 -17
  67. package/templates/clean-architecture/ts/src/interfaces/graphql/index.ts.ejs +3 -3
  68. package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/index.ts.ejs +4 -4
  69. package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.spec.ts.ejs +68 -51
  70. package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.ts.ejs +29 -21
  71. package/templates/clean-architecture/ts/src/interfaces/graphql/typeDefs/index.ts.ejs +4 -4
  72. package/templates/clean-architecture/ts/src/interfaces/graphql/typeDefs/user.types.ts.ejs +17 -15
  73. package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.spec.ts.ejs +40 -40
  74. package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.ts +13 -11
  75. package/templates/clean-architecture/ts/src/usecases/createUser.spec.ts.ejs +51 -51
  76. package/templates/clean-architecture/ts/src/usecases/createUser.ts +13 -13
  77. package/templates/clean-architecture/ts/src/usecases/deleteUser.spec.ts.ejs +47 -0
  78. package/templates/clean-architecture/ts/src/usecases/deleteUser.ts +9 -0
  79. package/templates/clean-architecture/ts/src/usecases/getAllUsers.spec.ts.ejs +63 -63
  80. package/templates/clean-architecture/ts/src/usecases/getAllUsers.ts +10 -10
  81. package/templates/clean-architecture/ts/src/usecases/updateUser.spec.ts.ejs +48 -0
  82. package/templates/clean-architecture/ts/src/usecases/updateUser.ts +9 -0
  83. package/templates/clean-architecture/ts/src/utils/errorMessages.ts +12 -0
  84. package/templates/clean-architecture/ts/src/utils/errorMiddleware.ts.ejs +27 -27
  85. package/templates/clean-architecture/ts/src/utils/httpCodes.ts +7 -7
  86. package/templates/common/.cursorrules.ejs +60 -60
  87. package/templates/common/.dockerignore +12 -12
  88. package/templates/common/.env.example.ejs +41 -41
  89. package/templates/common/.gitattributes +46 -0
  90. package/templates/common/.gitlab-ci.yml.ejs +86 -86
  91. package/templates/common/.lintstagedrc +6 -6
  92. package/templates/common/.prettierrc +7 -7
  93. package/templates/common/Dockerfile +73 -73
  94. package/templates/common/Jenkinsfile.ejs +87 -87
  95. package/templates/common/README.md.ejs +294 -270
  96. package/templates/common/SECURITY.md +20 -20
  97. package/templates/common/_github/workflows/ci.yml.ejs +46 -46
  98. package/templates/common/_github/workflows/security.yml.ejs +36 -36
  99. package/templates/common/_gitignore +5 -5
  100. package/templates/common/_husky/pre-commit +4 -4
  101. package/templates/common/caching/clean/js/CreateUser.js.ejs +29 -29
  102. package/templates/common/caching/clean/js/DeleteUser.js.ejs +27 -0
  103. package/templates/common/caching/clean/js/GetAllUsers.js.ejs +37 -37
  104. package/templates/common/caching/clean/js/UpdateUser.js.ejs +27 -0
  105. package/templates/common/caching/clean/ts/createUser.ts.ejs +27 -27
  106. package/templates/common/caching/clean/ts/deleteUser.ts.ejs +24 -0
  107. package/templates/common/caching/clean/ts/getAllUsers.ts.ejs +34 -34
  108. package/templates/common/caching/clean/ts/updateUser.ts.ejs +25 -0
  109. package/templates/common/caching/js/memoryCache.js.ejs +60 -60
  110. package/templates/common/caching/js/memoryCache.spec.js.ejs +101 -101
  111. package/templates/common/caching/js/redisClient.js.ejs +75 -75
  112. package/templates/common/caching/js/redisClient.spec.js.ejs +147 -147
  113. package/templates/common/caching/ts/memoryCache.spec.ts.ejs +102 -102
  114. package/templates/common/caching/ts/memoryCache.ts.ejs +73 -64
  115. package/templates/common/caching/ts/redisClient.spec.ts.ejs +157 -157
  116. package/templates/common/caching/ts/redisClient.ts.ejs +89 -80
  117. package/templates/common/database/js/database.js.ejs +19 -19
  118. package/templates/common/database/js/database.spec.js.ejs +56 -56
  119. package/templates/common/database/js/models/User.js.ejs +79 -53
  120. package/templates/common/database/js/models/User.js.mongoose.ejs +23 -19
  121. package/templates/common/database/js/models/User.spec.js.ejs +94 -84
  122. package/templates/common/database/js/mongoose.js.ejs +33 -33
  123. package/templates/common/database/js/mongoose.spec.js.ejs +43 -43
  124. package/templates/common/database/ts/database.spec.ts.ejs +56 -56
  125. package/templates/common/database/ts/database.ts.ejs +21 -21
  126. package/templates/common/database/ts/models/User.spec.ts.ejs +100 -84
  127. package/templates/common/database/ts/models/User.ts.ejs +87 -61
  128. package/templates/common/database/ts/models/User.ts.mongoose.ejs +30 -25
  129. package/templates/common/database/ts/mongoose.spec.ts.ejs +42 -42
  130. package/templates/common/database/ts/mongoose.ts.ejs +28 -28
  131. package/templates/common/docker-compose.yml.ejs +159 -159
  132. package/templates/common/ecosystem.config.js.ejs +40 -40
  133. package/templates/common/eslint.config.mjs.ejs +77 -77
  134. package/templates/common/health/js/healthRoute.js.ejs +50 -47
  135. package/templates/common/health/js/healthRoute.spec.js.ejs +70 -70
  136. package/templates/common/health/ts/healthRoute.spec.ts.ejs +76 -76
  137. package/templates/common/health/ts/healthRoute.ts.ejs +49 -46
  138. package/templates/common/jest.config.js.ejs +32 -32
  139. package/templates/common/jest.e2e.config.js.ejs +8 -8
  140. package/templates/common/kafka/js/config/kafka.js +9 -9
  141. package/templates/common/kafka/js/config/kafka.spec.js.ejs +27 -27
  142. package/templates/common/kafka/js/messaging/baseConsumer.js.ejs +30 -30
  143. package/templates/common/kafka/js/messaging/baseConsumer.spec.js.ejs +58 -58
  144. package/templates/common/kafka/js/messaging/userEventSchema.js.ejs +12 -11
  145. package/templates/common/kafka/js/messaging/userEventSchema.spec.js.ejs +27 -27
  146. package/templates/common/kafka/js/messaging/welcomeEmailConsumer.js.ejs +44 -31
  147. package/templates/common/kafka/js/messaging/welcomeEmailConsumer.spec.js.ejs +86 -49
  148. package/templates/common/kafka/js/services/kafkaService.js.ejs +93 -93
  149. package/templates/common/kafka/js/services/kafkaService.spec.js.ejs +106 -106
  150. package/templates/common/kafka/js/utils/kafkaEvents.js.ejs +7 -0
  151. package/templates/common/kafka/ts/config/kafka.spec.ts.ejs +27 -27
  152. package/templates/common/kafka/ts/config/kafka.ts +7 -7
  153. package/templates/common/kafka/ts/messaging/baseConsumer.spec.ts.ejs +50 -50
  154. package/templates/common/kafka/ts/messaging/baseConsumer.ts.ejs +27 -27
  155. package/templates/common/kafka/ts/messaging/userEventSchema.spec.ts.ejs +51 -51
  156. package/templates/common/kafka/ts/messaging/userEventSchema.ts.ejs +12 -11
  157. package/templates/common/kafka/ts/messaging/welcomeEmailConsumer.spec.ts.ejs +86 -49
  158. package/templates/common/kafka/ts/messaging/welcomeEmailConsumer.ts.ejs +38 -25
  159. package/templates/common/kafka/ts/services/kafkaService.spec.ts.ejs +81 -81
  160. package/templates/common/kafka/ts/services/kafkaService.ts.ejs +95 -95
  161. package/templates/common/kafka/ts/utils/kafkaEvents.ts.ejs +5 -0
  162. package/templates/common/migrate-mongo-config.js.ejs +31 -31
  163. package/templates/common/migrations/init.js.ejs +23 -23
  164. package/templates/common/package.json.ejs +119 -118
  165. package/templates/common/prompts/add-feature.md.ejs +26 -26
  166. package/templates/common/prompts/project-context.md.ejs +43 -43
  167. package/templates/common/prompts/troubleshoot.md.ejs +28 -28
  168. package/templates/common/public/css/style.css +147 -147
  169. package/templates/common/scripts/run-e2e.js.ejs +63 -63
  170. package/templates/common/shutdown/js/gracefulShutdown.js.ejs +65 -61
  171. package/templates/common/shutdown/js/gracefulShutdown.spec.js.ejs +149 -160
  172. package/templates/common/shutdown/ts/gracefulShutdown.spec.ts.ejs +179 -158
  173. package/templates/common/shutdown/ts/gracefulShutdown.ts.ejs +59 -55
  174. package/templates/common/sonar-project.properties.ejs +27 -27
  175. package/templates/common/src/tests/e2e/e2e.users.test.js.ejs +120 -49
  176. package/templates/common/src/tests/e2e/e2e.users.test.ts.ejs +120 -49
  177. package/templates/common/src/utils/errorMiddleware.spec.js.ejs +79 -79
  178. package/templates/common/src/utils/errorMiddleware.spec.ts.ejs +94 -94
  179. package/templates/common/swagger.yml.ejs +118 -66
  180. package/templates/common/tsconfig.json +22 -22
  181. package/templates/common/views/ejs/index.ejs +55 -55
  182. package/templates/common/views/pug/index.pug +40 -40
  183. package/templates/db/mysql/V1__Initial_Setup.sql.ejs +10 -9
  184. package/templates/db/postgres/V1__Initial_Setup.sql.ejs +10 -9
  185. package/templates/mvc/js/src/config/env.js.ejs +46 -46
  186. package/templates/mvc/js/src/config/swagger.js.ejs +6 -6
  187. package/templates/mvc/js/src/controllers/userController.js.ejs +246 -105
  188. package/templates/mvc/js/src/controllers/userController.spec.js.ejs +481 -209
  189. package/templates/mvc/js/src/errors/ApiError.js +14 -14
  190. package/templates/mvc/js/src/errors/BadRequestError.js +11 -10
  191. package/templates/mvc/js/src/errors/BadRequestError.spec.js.ejs +22 -21
  192. package/templates/mvc/js/src/errors/NotFoundError.js +11 -10
  193. package/templates/mvc/js/src/errors/NotFoundError.spec.js.ejs +22 -21
  194. package/templates/mvc/js/src/graphql/context.js.ejs +7 -7
  195. package/templates/mvc/js/src/graphql/context.spec.js.ejs +29 -29
  196. package/templates/mvc/js/src/graphql/index.js.ejs +5 -5
  197. package/templates/mvc/js/src/graphql/resolvers/index.js.ejs +6 -6
  198. package/templates/mvc/js/src/graphql/resolvers/user.resolvers.js.ejs +25 -19
  199. package/templates/mvc/js/src/graphql/resolvers/user.resolvers.spec.js.ejs +64 -47
  200. package/templates/mvc/js/src/graphql/typeDefs/index.js.ejs +6 -6
  201. package/templates/mvc/js/src/graphql/typeDefs/user.types.js.ejs +19 -17
  202. package/templates/mvc/js/src/index.js.ejs +136 -136
  203. package/templates/mvc/js/src/routes/api.js +10 -8
  204. package/templates/mvc/js/src/routes/api.spec.js.ejs +41 -36
  205. package/templates/mvc/js/src/utils/errorMessages.js +14 -0
  206. package/templates/mvc/js/src/utils/errorMiddleware.js +29 -29
  207. package/templates/mvc/js/src/utils/httpCodes.js +9 -9
  208. package/templates/mvc/js/src/utils/logger.js +40 -40
  209. package/templates/mvc/js/src/utils/logger.spec.js.ejs +63 -63
  210. package/templates/mvc/ts/src/config/env.ts.ejs +45 -45
  211. package/templates/mvc/ts/src/config/swagger.ts.ejs +6 -6
  212. package/templates/mvc/ts/src/controllers/userController.spec.ts.ejs +481 -203
  213. package/templates/mvc/ts/src/controllers/userController.ts.ejs +248 -107
  214. package/templates/mvc/ts/src/errors/ApiError.ts +15 -15
  215. package/templates/mvc/ts/src/errors/BadRequestError.spec.ts.ejs +22 -21
  216. package/templates/mvc/ts/src/errors/BadRequestError.ts +9 -8
  217. package/templates/mvc/ts/src/errors/NotFoundError.spec.ts.ejs +27 -21
  218. package/templates/mvc/ts/src/errors/NotFoundError.ts +9 -8
  219. package/templates/mvc/ts/src/graphql/context.spec.ts.ejs +30 -30
  220. package/templates/mvc/ts/src/graphql/context.ts.ejs +12 -12
  221. package/templates/mvc/ts/src/graphql/index.ts.ejs +3 -3
  222. package/templates/mvc/ts/src/graphql/resolvers/index.ts.ejs +4 -4
  223. package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.spec.ts.ejs +68 -51
  224. package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.ts.ejs +29 -21
  225. package/templates/mvc/ts/src/graphql/typeDefs/index.ts.ejs +4 -4
  226. package/templates/mvc/ts/src/graphql/typeDefs/user.types.ts.ejs +17 -15
  227. package/templates/mvc/ts/src/index.ts.ejs +156 -153
  228. package/templates/mvc/ts/src/routes/api.spec.ts.ejs +59 -40
  229. package/templates/mvc/ts/src/routes/api.ts +12 -10
  230. package/templates/mvc/ts/src/utils/errorMessages.ts +12 -0
  231. package/templates/mvc/ts/src/utils/errorMiddleware.ts.ejs +27 -27
  232. package/templates/mvc/ts/src/utils/httpCodes.ts +7 -7
  233. package/templates/mvc/ts/src/utils/logger.spec.ts.ejs +63 -63
  234. package/templates/mvc/ts/src/utils/logger.ts +36 -36
  235. package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.ts.ejs +0 -37
@@ -1,23 +1,23 @@
1
- module.exports = {
2
- async up(db, client) {
3
- const adminEmail = 'admin@example.com';
4
- const existingAdmin = await db.collection('users').findOne({ email: adminEmail });
5
-
6
- if (!existingAdmin) {
7
- await db.collection('users').insertOne({
8
- name: 'Admin User',
9
- email: adminEmail,
10
- createdAt: new Date(),
11
- updatedAt: new Date()
12
- });
13
- console.log('Admin User seeded successfully');
14
- } else {
15
- console.log('Admin User already exists, skipping seed');
16
- }
17
- },
18
-
19
- async down(db, client) {
20
- // Optional: Undo the seed. Usually for seeds we might want to keep data, but strictly speaking 'down' should reverse 'up'.
21
- // await db.collection('users').deleteOne({ email: 'admin@example.com' });
22
- }
23
- };
1
+ module.exports = {
2
+ async up(db, client) {
3
+ const adminEmail = 'admin@example.com';
4
+ const existingAdmin = await db.collection('users').findOne({ email: adminEmail });
5
+
6
+ if (!existingAdmin) {
7
+ await db.collection('users').insertOne({
8
+ name: 'Admin User',
9
+ email: adminEmail,
10
+ createdAt: new Date(),
11
+ updatedAt: new Date()
12
+ });
13
+ console.log('Admin User seeded successfully');
14
+ } else {
15
+ console.log('Admin User already exists, skipping seed');
16
+ }
17
+ },
18
+
19
+ async down(db, client) {
20
+ // Optional: Undo the seed. Usually for seeds we might want to keep data, but strictly speaking 'down' should reverse 'up'.
21
+ // await db.collection('users').deleteOne({ email: 'admin@example.com' });
22
+ }
23
+ };
@@ -1,118 +1,119 @@
1
- {
2
- "name": "<%= projectName %>",
3
- "version": "1.0.0",
4
- "description": "Generated by nodejs-quickstart",
5
- "main": "<% if (language === 'TypeScript') { %>dist/index.js<% } else { %>src/index.js<% } %>",
6
- "scripts": {
7
- "start": "<% if (language === 'TypeScript') { %>node dist/index.js<% } else { %>node src/index.js<% } %>",
8
- "dev": "<% if (language === 'TypeScript') { %>nodemon --exec ts-node -r tsconfig-paths/register src/index.ts<% } else { %>nodemon src/index.js<% } %>"<% if (language === 'TypeScript') { %>,
9
- "build": "rimraf dist && tsc && tsc-alias<% if (viewEngine && viewEngine !== 'None') { %> && cpx \"src/views/**/*\" dist/views<% } %><% if (communication === 'REST APIs' || communication === 'Kafka') { %> && cpx \"src/**/*.yml\" dist/<% } %>"<% } %>,
10
- "deploy": "npx pm2 start ecosystem.config.js --env production",
11
- "lint": "eslint .",
12
- "lint:fix": "eslint . --fix",
13
- "format": "prettier --write .",
14
- "prepare": "node -e \"if (require('fs').existsSync('.git')) { try { require('child_process').execSync('husky install', { stdio: 'inherit' }); } catch (e) { console.error('Husky installation failed:', e.message); } }\"",
15
- <% if (database === 'MongoDB') { %> "migrate": "migrate-mongo up",
16
- <% } -%>
17
- "test": "jest",
18
- "test:watch": "jest --watch",
19
- "test:coverage": "jest --coverage",
20
- "test:e2e:run": "jest --config ./jest.e2e.config.js --passWithNoTests",
21
- "test:e2e": "node scripts/run-e2e.js"<% if (includeSecurity) { %>,
22
- "security:check": "npm audit && npm run snyk:test",
23
- "snyk:test": "snyk test"<% } %>
24
- },
25
- "overrides": {
26
- "brace-expansion": "^5.0.5",
27
- "jake": "^10.9.4",
28
- "micromatch": "^4.0.8",
29
- "braces": "^3.0.3",
30
- "picomatch": "^4.0.4"
31
- },
32
- "dependencies": {
33
- "express": "^4.18.2",
34
- "dotenv": "^16.3.1",
35
- "zod": "^3.22.4",
36
- <% if (database === 'MySQL') { %> "mysql2": "^3.6.5",
37
- "sequelize": "^6.35.2",
38
- <% } -%>
39
- <% if (database === 'PostgreSQL') { %> "pg": "^8.11.3",
40
- "sequelize": "^6.35.2",
41
- <% } -%>
42
- <% if (database === 'MongoDB') { %> "mongoose": "^8.0.3",
43
- "migrate-mongo": "^11.0.0",
44
- <% } -%>
45
- <% if (communication === 'Kafka') { %> "kafkajs": "^2.2.4",
46
- <% } -%>
47
- <% if (caching === 'Redis') { %> "ioredis": "^5.3.2",
48
- <% } -%>
49
- <% if (caching === 'Memory Cache') { %> "node-cache": "^5.1.2",
50
- <% } -%>
51
- <% if (viewEngine === 'EJS') { %> "ejs": "^3.1.10",
52
- <% } -%>
53
- <% if (viewEngine === 'Pug') { %> "pug": "^3.0.2",
54
- <% } -%>
55
- "cors": "^2.8.5",
56
- "helmet": "^7.1.0",
57
- "hpp": "^0.2.3",
58
- "express-rate-limit": "^7.1.5",
59
- "winston": "^3.11.0",
60
- "winston-daily-rotate-file": "^5.0.0",
61
- "morgan": "^1.10.0"<% if (communication === 'REST APIs' || communication === 'Kafka') { %>,
62
- "swagger-ui-express": "^5.0.0",
63
- "yamljs": "^0.3.0"<% } %><% if (communication === 'GraphQL') { %>,
64
- "@apollo/server": "^5.5.0",
65
- "@as-integrations/express4": "^1.1.2",
66
- "graphql": "^16.8.1",
67
- "@graphql-tools/merge": "^9.0.3"<% } %>
68
- },
69
- "devDependencies": {
70
- "nodemon": "^3.0.2"<% if (language === 'TypeScript') { %>,
71
- "typescript": "^5.3.3",
72
- "ts-node": "^10.9.2",
73
- "@types/node": "^20.10.5",
74
- "@types/express": "^4.17.21",
75
- "@types/cors": "^2.8.17",
76
- "@types/hpp": "^0.2.3",
77
- <% if (caching === 'Memory Cache') { %> "@types/node-cache": "^4.2.5",
78
- <% } -%>
79
- <% if (database === 'PostgreSQL') { %> "@types/pg": "^8.10.9",
80
- <% } -%>
81
- <% if (database === 'MySQL' || database === 'PostgreSQL') { -%>
82
- "@types/sequelize": "^4.28.19",
83
- <% } -%>
84
- "@types/morgan": "^1.9.9",
85
- "rimraf": "^6.0.1"<% if ((viewEngine && viewEngine !== 'None') || communication === 'REST APIs' || communication === 'Kafka') { %>,
86
- "cpx2": "^8.0.0"<% } %><% } %>,
87
- "eslint": "^10.1.0",
88
- "@eslint/js": "^9.20.0",
89
- "globals": "^15.14.0",
90
- "prettier": "^3.5.1",
91
- "eslint-config-prettier": "^10.0.1",
92
- "eslint-plugin-import-x": "^4.6.1",
93
- "eslint-import-resolver-typescript": "^3.7.0",
94
- "husky": "^8.0.3",
95
- "lint-staged": "^15.4.3",
96
- "snyk": "^1.1295.0"<% if (language === 'TypeScript') { %>,
97
- "typescript-eslint": "^8.24.1",<%_ if (communication === 'REST APIs' || communication === 'Kafka') { %>
98
- "@types/swagger-ui-express": "^4.1.6",
99
- "@types/yamljs": "^0.2.34",<%_ } %>
100
- "jest": "^29.7.0",
101
- "ts-jest": "^29.2.5",
102
- "@types/jest": "^29.5.14",
103
- "wait-on": "^7.2.0",
104
- "supertest": "^7.1.3",
105
- "tsconfig-paths": "^4.2.0",
106
- "tsc-alias": "^1.8.10",
107
- "@types/supertest": "^6.0.2"<% } else { %>,
108
- "jest": "^29.7.0",
109
- "wait-on": "^7.2.0",
110
- "supertest": "^7.1.3"<% } %>
111
- },
112
- "lint-staged": {
113
- "*.{js,ts}": [
114
- "eslint --fix",
115
- "prettier --write"
116
- ]
117
- }
118
- }
1
+ {
2
+ "name": "<%= projectName %>",
3
+ "version": "1.0.0",
4
+ "description": "Generated by nodejs-quickstart",
5
+ "main": "<% if (language === 'TypeScript') { %>dist/index.js<% } else { %>src/index.js<% } %>",
6
+ "scripts": {
7
+ "start": "<% if (language === 'TypeScript') { %>node dist/index.js<% } else { %>node src/index.js<% } %>",
8
+ "dev": "<% if (language === 'TypeScript') { %>nodemon --exec ts-node -r tsconfig-paths/register src/index.ts<% } else { %>nodemon src/index.js<% } %>"<% if (language === 'TypeScript') { %>,
9
+ "build": "rimraf dist && tsc && tsc-alias<% if (viewEngine && viewEngine !== 'None') { %> && cpx \"src/views/**/*\" dist/views<% } %><% if (communication === 'REST APIs' || communication === 'Kafka') { %> && cpx \"src/**/*.yml\" dist/<% } %>"<% } %>,
10
+ "deploy": "npx pm2 start ecosystem.config.js --env production",
11
+ "lint": "eslint .",
12
+ "lint:fix": "eslint . --fix",
13
+ "format": "prettier --write .",
14
+ "prepare": "node -e \"if (require('fs').existsSync('.git')) { try { require('child_process').execSync('husky install', { stdio: 'inherit' }); } catch (e) { console.error('Husky installation failed:', e.message); } }\"",
15
+ <% if (database === 'MongoDB') { %> "migrate": "migrate-mongo up",
16
+ <% } -%>
17
+ "test": "jest",
18
+ "test:watch": "jest --watch",
19
+ "test:coverage": "jest --coverage",
20
+ "test:e2e:run": "jest --config ./jest.e2e.config.js --passWithNoTests",
21
+ "test:e2e": "node scripts/run-e2e.js"<% if (includeSecurity) { %>,
22
+ "security:check": "npm audit && npm run snyk:test",
23
+ "snyk:test": "snyk test"<% } %>
24
+ },
25
+ "overrides": {
26
+ "brace-expansion": "^5.0.5",
27
+ "jake": "^11.9.5",
28
+ "micromatch": "^4.0.8",
29
+ "braces": "^3.0.3",
30
+ "picomatch": "^4.0.4",
31
+ "lodash": "^4.17.23"
32
+ },
33
+ "dependencies": {
34
+ "express": "^4.18.2",
35
+ "dotenv": "^16.3.1",
36
+ "zod": "^3.22.4",
37
+ <% if (database === 'MySQL') { %> "mysql2": "^3.6.5",
38
+ "sequelize": "^6.35.2",
39
+ <% } -%>
40
+ <% if (database === 'PostgreSQL') { %> "pg": "^8.11.3",
41
+ "sequelize": "^6.35.2",
42
+ <% } -%>
43
+ <% if (database === 'MongoDB') { %> "mongoose": "^8.0.3",
44
+ "migrate-mongo": "^11.0.0",
45
+ <% } -%>
46
+ <% if (communication === 'Kafka') { %> "kafkajs": "^2.2.4",
47
+ <% } -%>
48
+ <% if (caching === 'Redis') { %> "ioredis": "^5.3.2",
49
+ <% } -%>
50
+ <% if (caching === 'Memory Cache') { %> "node-cache": "^5.1.2",
51
+ <% } -%>
52
+ <% if (viewEngine === 'EJS') { %> "ejs": "^3.1.10",
53
+ <% } -%>
54
+ <% if (viewEngine === 'Pug') { %> "pug": "^3.0.2",
55
+ <% } -%>
56
+ "cors": "^2.8.5",
57
+ "helmet": "^7.1.0",
58
+ "hpp": "^0.2.3",
59
+ "express-rate-limit": "^7.1.5",
60
+ "winston": "^3.11.0",
61
+ "winston-daily-rotate-file": "^5.0.0",
62
+ "morgan": "^1.10.0"<% if (communication === 'REST APIs' || communication === 'Kafka') { %>,
63
+ "swagger-ui-express": "^5.0.0",
64
+ "yamljs": "^0.3.0"<% } %><% if (communication === 'GraphQL') { %>,
65
+ "@apollo/server": "^5.5.0",
66
+ "@as-integrations/express4": "^1.1.2",
67
+ "graphql": "^16.8.1",
68
+ "@graphql-tools/merge": "^9.0.3"<% } %>
69
+ },
70
+ "devDependencies": {
71
+ "nodemon": "^3.0.2"<% if (language === 'TypeScript') { %>,
72
+ "typescript": "^5.3.3",
73
+ "ts-node": "^10.9.2",
74
+ "@types/node": "^20.10.5",
75
+ "@types/express": "^4.17.21",
76
+ "@types/cors": "^2.8.17",
77
+ "@types/hpp": "^0.2.3",
78
+ <% if (caching === 'Memory Cache') { %> "@types/node-cache": "^4.2.5",
79
+ <% } -%>
80
+ <% if (database === 'PostgreSQL') { %> "@types/pg": "^8.10.9",
81
+ <% } -%>
82
+ <% if (database === 'MySQL' || database === 'PostgreSQL') { -%>
83
+ "@types/sequelize": "^4.28.19",
84
+ <% } -%>
85
+ "@types/morgan": "^1.9.9",
86
+ "rimraf": "^6.0.1"<% if ((viewEngine && viewEngine !== 'None') || communication === 'REST APIs' || communication === 'Kafka') { %>,
87
+ "cpx2": "^8.0.0"<% } %><% } %>,
88
+ "eslint": "^10.1.0",
89
+ "@eslint/js": "^9.20.0",
90
+ "globals": "^15.14.0",
91
+ "prettier": "^3.5.1",
92
+ "eslint-config-prettier": "^10.0.1",
93
+ "eslint-plugin-import-x": "^4.6.1",
94
+ "eslint-import-resolver-typescript": "^3.7.0",
95
+ "husky": "^8.0.3",
96
+ "lint-staged": "^15.4.3",
97
+ "snyk": "^1.1295.0"<% if (language === 'TypeScript') { %>,
98
+ "typescript-eslint": "^8.24.1",<%_ if (communication === 'REST APIs' || communication === 'Kafka') { %>
99
+ "@types/swagger-ui-express": "^4.1.6",
100
+ "@types/yamljs": "^0.2.34",<%_ } %>
101
+ "jest": "^29.7.0",
102
+ "ts-jest": "^29.2.5",
103
+ "@types/jest": "^29.5.14",
104
+ "wait-on": "^7.2.0",
105
+ "supertest": "^7.1.3",
106
+ "tsconfig-paths": "^4.2.0",
107
+ "tsc-alias": "^1.8.10",
108
+ "@types/supertest": "^6.0.2"<% } else { %>,
109
+ "jest": "^29.7.0",
110
+ "wait-on": "^7.2.0",
111
+ "supertest": "^7.1.3"<% } %>
112
+ },
113
+ "lint-staged": {
114
+ "*.{js,ts}": [
115
+ "eslint --fix",
116
+ "prettier --write"
117
+ ]
118
+ }
119
+ }
@@ -1,26 +1,26 @@
1
- # Add New Feature
2
-
3
- I want to add a new feature to the existing application.
4
- Please follow the strict standards defined in the project context.
5
-
6
- ## Feature Description
7
- [INSERT EXPLANATION OF WHAT YOU WANT TO ADD HERE]
8
-
9
- ## Implementation Guidelines
10
-
11
- Please provide the code implementation following these steps:
12
-
13
- 1. **Plan first**: Outline the files you need to create/modify and the logic they'll contain.
14
- <% if (architecture === 'Clean Architecture') { -%>
15
- 2. **Domain/Entity**: Define the core entity structure or interfaces if applicable.
16
- 3. **Use Case**: Implement the business logic handling the feature.
17
- 4. **Adapter (Controller & Route)**: Create the necessary endpoints and validate input.
18
- 5. **Infrastructure (Repository)**: Implement database queries or external service calls.
19
- <% } else { -%>
20
- 2. **Model**: Define the database schema/model if applicable.
21
- 3. **Controller**: Implement the business logic and request handling.
22
- 4. **Route**: Create the API endpoints and wire them to the controller.
23
- <% } -%>
24
- 6. **Testing**: Write comprehensive Jest unit tests covering the "Happy Path" and "Edge Cases/Errors" (AAA pattern). Remember, our coverage requirement is > 80%!
25
-
26
- Please provide the plan first so I can review it before we write the code.
1
+ # Add New Feature
2
+
3
+ I want to add a new feature to the existing application.
4
+ Please follow the strict standards defined in the project context.
5
+
6
+ ## Feature Description
7
+ [INSERT EXPLANATION OF WHAT YOU WANT TO ADD HERE]
8
+
9
+ ## Implementation Guidelines
10
+
11
+ Please provide the code implementation following these steps:
12
+
13
+ 1. **Plan first**: Outline the files you need to create/modify and the logic they'll contain.
14
+ <% if (architecture === 'Clean Architecture') { -%>
15
+ 2. **Domain/Entity**: Define the core entity structure or interfaces if applicable.
16
+ 3. **Use Case**: Implement the business logic handling the feature.
17
+ 4. **Adapter (Controller & Route)**: Create the necessary endpoints and validate input.
18
+ 5. **Infrastructure (Repository)**: Implement database queries or external service calls.
19
+ <% } else { -%>
20
+ 2. **Model**: Define the database schema/model if applicable.
21
+ 3. **Controller**: Implement the business logic and request handling.
22
+ 4. **Route**: Create the API endpoints and wire them to the controller.
23
+ <% } -%>
24
+ 6. **Testing**: Write comprehensive Jest unit tests covering the "Happy Path" and "Edge Cases/Errors" (AAA pattern). Remember, our coverage requirement is > 80%!
25
+
26
+ Please provide the plan first so I can review it before we write the code.
@@ -1,43 +1,43 @@
1
- # Project Context
2
-
3
- Hello AI! I am working on a Node.js project. Here is the context to help you understand the architecture, domain, and standards.
4
-
5
- ## Domain Overview
6
- **Project Name**: <%= projectName %>
7
- You are an expert working on **<%= projectName %>**.
8
- **Project Goal**: [Replace this with your business logic, e.g., E-commerce API]
9
- *(Keep this goal in mind when writing business logic, proposing data schemas, or considering edge cases like security and performance.)*
10
-
11
- ## Tech Stack
12
- - **Language**: <%= language %>
13
- - **Architecture**: <%= architecture %>
14
- - **Database**: <%= database %>
15
- - **Communication Protocol**: <%= communication %>
16
- <% if (caching !== 'None') { -%>
17
- - **Caching**: <%= caching %>
18
- <% } -%>
19
-
20
- ## High-Level Architecture
21
- <% if (architecture === 'Clean Architecture') { -%>
22
- We use Clean Architecture. The project separates concerns into:
23
- - `src/domain`: Core entities and rules. No external dependencies.
24
- - `src/usecases`: Application business logic.
25
- - `src/interfaces`: Adapters (Controllers, Routes) that mediate between the outside world and use cases.
26
- - `src/infrastructure`: External tools (Database, Web Server, Config, Caching).
27
- <% } else { -%>
28
- We use the MVC (Model-View-Controller) pattern.
29
- - `src/models`: Database schemas/models.
30
- - `src/controllers`: Handling incoming requests and implementing business logic.
31
- - `src/routes`: API endpoints mapped to controllers.
32
- <% } -%>
33
-
34
- ## Core Standards
35
- 1. **Testing**: We enforce > 80% coverage. Tests use Jest and the AAA (Arrange, Act, Assert) pattern.
36
- 2. **Error Handling**: We use centralized custom errors (e.g., `ApiError`) and global error middleware. Status codes come from standard constants, not hardcoded numbers.
37
- 3. **Paths & Naming**:
38
- <% if (language === 'TypeScript') { -%>
39
- - We use `@/` path aliases for internal imports.
40
- <% } -%>
41
- - Files are mostly `camelCase`.
42
-
43
- Please acknowledge you understand this context by saying "Context loaded successfully! How can I help you build the <%= projectName %>?"
1
+ # Project Context
2
+
3
+ Hello AI! I am working on a Node.js project. Here is the context to help you understand the architecture, domain, and standards.
4
+
5
+ ## Domain Overview
6
+ **Project Name**: <%= projectName %>
7
+ You are an expert working on **<%= projectName %>**.
8
+ **Project Goal**: [Replace this with your business logic, e.g., E-commerce API]
9
+ *(Keep this goal in mind when writing business logic, proposing data schemas, or considering edge cases like security and performance.)*
10
+
11
+ ## Tech Stack
12
+ - **Language**: <%= language %>
13
+ - **Architecture**: <%= architecture %>
14
+ - **Database**: <%= database %>
15
+ - **Communication Protocol**: <%= communication %>
16
+ <% if (caching !== 'None') { -%>
17
+ - **Caching**: <%= caching %>
18
+ <% } -%>
19
+
20
+ ## High-Level Architecture
21
+ <% if (architecture === 'Clean Architecture') { -%>
22
+ We use Clean Architecture. The project separates concerns into:
23
+ - `src/domain`: Core entities and rules. No external dependencies.
24
+ - `src/usecases`: Application business logic.
25
+ - `src/interfaces`: Adapters (Controllers, Routes) that mediate between the outside world and use cases.
26
+ - `src/infrastructure`: External tools (Database, Web Server, Config, Caching).
27
+ <% } else { -%>
28
+ We use the MVC (Model-View-Controller) pattern.
29
+ - `src/models`: Database schemas/models.
30
+ - `src/controllers`: Handling incoming requests and implementing business logic.
31
+ - `src/routes`: API endpoints mapped to controllers.
32
+ <% } -%>
33
+
34
+ ## Core Standards
35
+ 1. **Testing**: We enforce > 80% coverage. Tests use Jest and the AAA (Arrange, Act, Assert) pattern.
36
+ 2. **Error Handling**: We use centralized custom errors (e.g., `ApiError`) and global error middleware. Status codes come from standard constants, not hardcoded numbers.
37
+ 3. **Paths & Naming**:
38
+ <% if (language === 'TypeScript') { -%>
39
+ - We use `@/` path aliases for internal imports.
40
+ <% } -%>
41
+ - Files are mostly `camelCase`.
42
+
43
+ Please acknowledge you understand this context by saying "Context loaded successfully! How can I help you build the <%= projectName %>?"
@@ -1,28 +1,28 @@
1
- # Troubleshoot Error
2
-
3
- I am encountering an error in the <%= projectName %> application. Please help me diagnose and fix it based on our architectural standards.
4
-
5
- ## The Error Log / Issue Description
6
- \`\`\`
7
- [PASTE YOUR ERROR LOG OR DESCRIBE THE ISSUE HERE]
8
- \`\`\`
9
-
10
- ## Context Variables
11
- - **Architecture**: <%= architecture %>
12
- - **Language**: <%= language %>
13
-
14
- ## Guidelines for Fixing
15
-
16
- When analyzing this error, please keep these project standards in mind:
17
-
18
- 1. **Centralized Error Handling**:
19
- - Ensure the error uses the standard custom error classes from `src/errors/` (e.g., `ApiError`, `NotFoundError`, `BadRequestError`).
20
- - If an error occurs in a controller, it should be passed to the global error middleware via `throw` (for async handlers, or `next(error)` in MVC).
21
- 2. **Standard Status Codes**:
22
- - Verify that appropriate status codes from `httpCodes` are being used correctly, rather than generic 500s unless unexpected.
23
- 3. **Dependencies**:
24
- - Check if this is a connection issue (e.g., Database, Kafka, Redis) and see if our standard configuration or health checks provide hints.
25
- 4. **Fix Suggestion**:
26
- - Explain *why* the error happened.
27
- - Provide a targeted code fix matching our coding style (<%= language %>, <%= architecture %>).
28
- - Only modify what is strictly necessary to solve the issue.
1
+ # Troubleshoot Error
2
+
3
+ I am encountering an error in the <%= projectName %> application. Please help me diagnose and fix it based on our architectural standards.
4
+
5
+ ## The Error Log / Issue Description
6
+ \`\`\`
7
+ [PASTE YOUR ERROR LOG OR DESCRIBE THE ISSUE HERE]
8
+ \`\`\`
9
+
10
+ ## Context Variables
11
+ - **Architecture**: <%= architecture %>
12
+ - **Language**: <%= language %>
13
+
14
+ ## Guidelines for Fixing
15
+
16
+ When analyzing this error, please keep these project standards in mind:
17
+
18
+ 1. **Centralized Error Handling**:
19
+ - Ensure the error uses the standard custom error classes from `src/errors/` (e.g., `ApiError`, `NotFoundError`, `BadRequestError`).
20
+ - If an error occurs in a controller, it should be passed to the global error middleware via `throw` (for async handlers, or `next(error)` in MVC).
21
+ 2. **Standard Status Codes**:
22
+ - Verify that appropriate status codes from `httpCodes` are being used correctly, rather than generic 500s unless unexpected.
23
+ 3. **Dependencies**:
24
+ - Check if this is a connection issue (e.g., Database, Kafka, Redis) and see if our standard configuration or health checks provide hints.
25
+ 4. **Fix Suggestion**:
26
+ - Explain *why* the error happened.
27
+ - Provide a targeted code fix matching our coding style (<%= language %>, <%= architecture %>).
28
+ - Only modify what is strictly necessary to solve the issue.