nodejs-quickstart-structure 1.19.0 → 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 (134) hide show
  1. package/CHANGELOG.md +309 -301
  2. package/LICENSE +15 -15
  3. package/lib/generator.js +139 -139
  4. package/lib/modules/app-setup.js +401 -401
  5. package/lib/modules/config-files.js +151 -151
  6. package/lib/modules/database-setup.js +116 -116
  7. package/lib/modules/project-setup.js +32 -32
  8. package/lib/prompts.js +100 -100
  9. package/package.json +78 -78
  10. package/templates/clean-architecture/js/src/domain/models/User.js +9 -9
  11. package/templates/clean-architecture/js/src/errors/ApiError.js +14 -14
  12. package/templates/clean-architecture/js/src/index.js.ejs +55 -55
  13. package/templates/clean-architecture/js/src/infrastructure/config/env.js.ejs +47 -47
  14. package/templates/clean-architecture/js/src/infrastructure/log/logger.js +36 -36
  15. package/templates/clean-architecture/js/src/infrastructure/log/logger.spec.js.ejs +63 -63
  16. package/templates/clean-architecture/js/src/infrastructure/webserver/middleware/errorMiddleware.js +30 -30
  17. package/templates/clean-architecture/js/src/infrastructure/webserver/server.js.ejs +89 -89
  18. package/templates/clean-architecture/js/src/infrastructure/webserver/swagger.js.ejs +6 -6
  19. package/templates/clean-architecture/js/src/interfaces/graphql/context.js.ejs +13 -13
  20. package/templates/clean-architecture/js/src/interfaces/graphql/context.spec.js.ejs +31 -31
  21. package/templates/clean-architecture/js/src/interfaces/graphql/index.js.ejs +5 -5
  22. package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/index.js.ejs +6 -6
  23. package/templates/clean-architecture/js/src/interfaces/graphql/typeDefs/index.js.ejs +6 -6
  24. package/templates/clean-architecture/js/src/interfaces/routes/api.spec.js.ejs +38 -38
  25. package/templates/clean-architecture/js/src/usecases/CreateUser.js +14 -14
  26. package/templates/clean-architecture/js/src/usecases/CreateUser.spec.js.ejs +51 -51
  27. package/templates/clean-architecture/js/src/usecases/GetAllUsers.js +12 -12
  28. package/templates/clean-architecture/js/src/usecases/GetAllUsers.spec.js.ejs +61 -61
  29. package/templates/clean-architecture/js/src/utils/httpCodes.js +9 -9
  30. package/templates/clean-architecture/ts/src/config/env.ts.ejs +46 -46
  31. package/templates/clean-architecture/ts/src/config/swagger.ts.ejs +6 -6
  32. package/templates/clean-architecture/ts/src/domain/user.ts +7 -7
  33. package/templates/clean-architecture/ts/src/errors/ApiError.ts +15 -15
  34. package/templates/clean-architecture/ts/src/index.ts.ejs +139 -139
  35. package/templates/clean-architecture/ts/src/infrastructure/log/logger.spec.ts.ejs +63 -63
  36. package/templates/clean-architecture/ts/src/infrastructure/log/logger.ts +36 -36
  37. package/templates/clean-architecture/ts/src/interfaces/graphql/context.spec.ts.ejs +32 -32
  38. package/templates/clean-architecture/ts/src/interfaces/graphql/context.ts.ejs +17 -17
  39. package/templates/clean-architecture/ts/src/interfaces/graphql/index.ts.ejs +3 -3
  40. package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/index.ts.ejs +4 -4
  41. package/templates/clean-architecture/ts/src/interfaces/graphql/typeDefs/index.ts.ejs +4 -4
  42. package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.spec.ts.ejs +40 -40
  43. package/templates/clean-architecture/ts/src/usecases/createUser.spec.ts.ejs +51 -51
  44. package/templates/clean-architecture/ts/src/usecases/createUser.ts +13 -13
  45. package/templates/clean-architecture/ts/src/usecases/getAllUsers.spec.ts.ejs +63 -63
  46. package/templates/clean-architecture/ts/src/usecases/getAllUsers.ts +10 -10
  47. package/templates/clean-architecture/ts/src/utils/errorMiddleware.ts.ejs +27 -27
  48. package/templates/clean-architecture/ts/src/utils/httpCodes.ts +7 -7
  49. package/templates/common/.cursorrules.ejs +60 -60
  50. package/templates/common/.dockerignore +12 -12
  51. package/templates/common/.env.example.ejs +41 -41
  52. package/templates/common/.gitlab-ci.yml.ejs +86 -86
  53. package/templates/common/.lintstagedrc +6 -6
  54. package/templates/common/.prettierrc +7 -7
  55. package/templates/common/Dockerfile +73 -73
  56. package/templates/common/Jenkinsfile.ejs +87 -87
  57. package/templates/common/SECURITY.md +20 -20
  58. package/templates/common/_github/workflows/ci.yml.ejs +46 -46
  59. package/templates/common/_github/workflows/security.yml.ejs +36 -36
  60. package/templates/common/_gitignore +5 -5
  61. package/templates/common/_husky/pre-commit +4 -4
  62. package/templates/common/caching/clean/js/CreateUser.js.ejs +29 -29
  63. package/templates/common/caching/clean/js/GetAllUsers.js.ejs +37 -37
  64. package/templates/common/caching/clean/ts/createUser.ts.ejs +27 -27
  65. package/templates/common/caching/clean/ts/getAllUsers.ts.ejs +34 -34
  66. package/templates/common/caching/js/memoryCache.js.ejs +60 -60
  67. package/templates/common/caching/js/memoryCache.spec.js.ejs +101 -101
  68. package/templates/common/caching/js/redisClient.js.ejs +75 -75
  69. package/templates/common/caching/js/redisClient.spec.js.ejs +147 -147
  70. package/templates/common/caching/ts/memoryCache.spec.ts.ejs +102 -102
  71. package/templates/common/caching/ts/redisClient.spec.ts.ejs +157 -157
  72. package/templates/common/database/js/database.js.ejs +19 -19
  73. package/templates/common/database/js/database.spec.js.ejs +56 -56
  74. package/templates/common/database/js/mongoose.js.ejs +33 -33
  75. package/templates/common/database/js/mongoose.spec.js.ejs +43 -43
  76. package/templates/common/database/ts/database.spec.ts.ejs +56 -56
  77. package/templates/common/database/ts/database.ts.ejs +21 -21
  78. package/templates/common/database/ts/mongoose.spec.ts.ejs +42 -42
  79. package/templates/common/database/ts/mongoose.ts.ejs +28 -28
  80. package/templates/common/docker-compose.yml.ejs +159 -159
  81. package/templates/common/ecosystem.config.js.ejs +40 -40
  82. package/templates/common/eslint.config.mjs.ejs +77 -77
  83. package/templates/common/health/js/healthRoute.spec.js.ejs +70 -70
  84. package/templates/common/health/ts/healthRoute.spec.ts.ejs +76 -76
  85. package/templates/common/jest.config.js.ejs +32 -32
  86. package/templates/common/kafka/js/config/kafka.js +9 -9
  87. package/templates/common/kafka/js/config/kafka.spec.js.ejs +27 -27
  88. package/templates/common/kafka/js/messaging/baseConsumer.spec.js.ejs +58 -58
  89. package/templates/common/kafka/js/messaging/userEventSchema.spec.js.ejs +27 -27
  90. package/templates/common/kafka/js/services/kafkaService.spec.js.ejs +106 -106
  91. package/templates/common/kafka/ts/config/kafka.spec.ts.ejs +27 -27
  92. package/templates/common/kafka/ts/config/kafka.ts +7 -7
  93. package/templates/common/kafka/ts/messaging/baseConsumer.spec.ts.ejs +50 -50
  94. package/templates/common/kafka/ts/messaging/baseConsumer.ts.ejs +27 -27
  95. package/templates/common/kafka/ts/services/kafkaService.spec.ts.ejs +81 -81
  96. package/templates/common/migrate-mongo-config.js.ejs +31 -31
  97. package/templates/common/migrations/init.js.ejs +23 -23
  98. package/templates/common/package.json.ejs +119 -118
  99. package/templates/common/prompts/add-feature.md.ejs +26 -26
  100. package/templates/common/prompts/project-context.md.ejs +43 -43
  101. package/templates/common/prompts/troubleshoot.md.ejs +28 -28
  102. package/templates/common/public/css/style.css +147 -147
  103. package/templates/common/scripts/run-e2e.js.ejs +63 -63
  104. package/templates/common/sonar-project.properties.ejs +27 -27
  105. package/templates/common/src/utils/errorMiddleware.spec.js.ejs +79 -79
  106. package/templates/common/src/utils/errorMiddleware.spec.ts.ejs +94 -94
  107. package/templates/common/tsconfig.json +22 -22
  108. package/templates/common/views/ejs/index.ejs +55 -55
  109. package/templates/common/views/pug/index.pug +40 -40
  110. package/templates/mvc/js/src/config/env.js.ejs +46 -46
  111. package/templates/mvc/js/src/config/swagger.js.ejs +6 -6
  112. package/templates/mvc/js/src/errors/ApiError.js +14 -14
  113. package/templates/mvc/js/src/graphql/context.js.ejs +7 -7
  114. package/templates/mvc/js/src/graphql/context.spec.js.ejs +29 -29
  115. package/templates/mvc/js/src/graphql/index.js.ejs +5 -5
  116. package/templates/mvc/js/src/graphql/resolvers/index.js.ejs +6 -6
  117. package/templates/mvc/js/src/graphql/typeDefs/index.js.ejs +6 -6
  118. package/templates/mvc/js/src/index.js.ejs +136 -136
  119. package/templates/mvc/js/src/utils/errorMiddleware.js +29 -29
  120. package/templates/mvc/js/src/utils/httpCodes.js +9 -9
  121. package/templates/mvc/js/src/utils/logger.js +40 -40
  122. package/templates/mvc/js/src/utils/logger.spec.js.ejs +63 -63
  123. package/templates/mvc/ts/src/config/env.ts.ejs +45 -45
  124. package/templates/mvc/ts/src/config/swagger.ts.ejs +6 -6
  125. package/templates/mvc/ts/src/errors/ApiError.ts +15 -15
  126. package/templates/mvc/ts/src/graphql/context.spec.ts.ejs +30 -30
  127. package/templates/mvc/ts/src/graphql/context.ts.ejs +12 -12
  128. package/templates/mvc/ts/src/graphql/index.ts.ejs +3 -3
  129. package/templates/mvc/ts/src/graphql/resolvers/index.ts.ejs +4 -4
  130. package/templates/mvc/ts/src/graphql/typeDefs/index.ts.ejs +4 -4
  131. package/templates/mvc/ts/src/utils/errorMiddleware.ts.ejs +27 -27
  132. package/templates/mvc/ts/src/utils/httpCodes.ts +7 -7
  133. package/templates/mvc/ts/src/utils/logger.spec.ts.ejs +63 -63
  134. package/templates/mvc/ts/src/utils/logger.ts +36 -36
@@ -1,31 +1,31 @@
1
- const config = {
2
- mongodb: {
3
- url: process.env.MONGO_URI || `mongodb://${process.env.DB_HOST || 'localhost'}:27017`,
4
- databaseName: process.env.DB_NAME || '<%= dbName %>',
5
-
6
- options: {
7
- // useNewUrlParser: true, // No longer needed in Node.js driver v4+
8
- // useUnifiedTopology: true, // No longer needed in Node.js driver v4+
9
- // connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
10
- // socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
11
- }
12
- },
13
-
14
- // The migrations dir, can be an relative or absolute path. Only edit this when really necessary.
15
- migrationsDir: "migrations",
16
-
17
- // The mongodb collection where the applied changes are stored. Only edit this when really necessary.
18
- changelogCollectionName: "changelog",
19
-
20
- // The file extension to create migrations and search for in migration dir
21
- migrationFileExtension: ".js",
22
-
23
- // Enable the algorithm to create a checksum of the file contents and use that in the comparison to determine
24
- // if the file should be run. Requires that scripts are coded to be run multiple times.
25
- useFileHash: false,
26
-
27
- // Don't change this, unless you know what you are doing
28
- moduleSystem: 'commonjs',
29
- };
30
-
31
- module.exports = config;
1
+ const config = {
2
+ mongodb: {
3
+ url: process.env.MONGO_URI || `mongodb://${process.env.DB_HOST || 'localhost'}:27017`,
4
+ databaseName: process.env.DB_NAME || '<%= dbName %>',
5
+
6
+ options: {
7
+ // useNewUrlParser: true, // No longer needed in Node.js driver v4+
8
+ // useUnifiedTopology: true, // No longer needed in Node.js driver v4+
9
+ // connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
10
+ // socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
11
+ }
12
+ },
13
+
14
+ // The migrations dir, can be an relative or absolute path. Only edit this when really necessary.
15
+ migrationsDir: "migrations",
16
+
17
+ // The mongodb collection where the applied changes are stored. Only edit this when really necessary.
18
+ changelogCollectionName: "changelog",
19
+
20
+ // The file extension to create migrations and search for in migration dir
21
+ migrationFileExtension: ".js",
22
+
23
+ // Enable the algorithm to create a checksum of the file contents and use that in the comparison to determine
24
+ // if the file should be run. Requires that scripts are coded to be run multiple times.
25
+ useFileHash: false,
26
+
27
+ // Don't change this, unless you know what you are doing
28
+ moduleSystem: 'commonjs',
29
+ };
30
+
31
+ module.exports = config;
@@ -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.