nodejs-quickstart-structure 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -3
- package/README.md +5 -3
- package/lib/generator.js +17 -3
- package/lib/modules/app-setup.js +167 -47
- package/lib/modules/caching-setup.js +13 -0
- package/lib/modules/config-files.js +25 -62
- package/lib/modules/database-setup.js +35 -30
- package/lib/modules/kafka-setup.js +79 -13
- package/package.json +1 -2
- package/templates/clean-architecture/js/src/errors/BadRequestError.js +1 -1
- package/templates/clean-architecture/js/src/errors/BadRequestError.spec.js.ejs +21 -0
- package/templates/clean-architecture/js/src/errors/NotFoundError.js +1 -1
- package/templates/clean-architecture/js/src/errors/NotFoundError.spec.js.ejs +21 -0
- package/templates/clean-architecture/js/src/infrastructure/log/logger.spec.js.ejs +63 -0
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.js.ejs +2 -3
- package/templates/clean-architecture/js/src/infrastructure/repositories/UserRepository.spec.js.ejs +81 -0
- package/templates/clean-architecture/js/src/infrastructure/webserver/server.js.ejs +20 -9
- package/templates/clean-architecture/js/src/interfaces/controllers/userController.js.ejs +8 -4
- package/templates/clean-architecture/js/src/interfaces/controllers/userController.spec.js.ejs +102 -0
- package/templates/clean-architecture/js/src/interfaces/graphql/context.spec.js.ejs +31 -0
- package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/user.resolvers.spec.js.ejs +49 -0
- package/templates/clean-architecture/js/src/interfaces/routes/api.spec.js.ejs +38 -0
- package/templates/clean-architecture/js/src/usecases/CreateUser.spec.js.ejs +51 -0
- package/templates/clean-architecture/js/src/usecases/GetAllUsers.spec.js.ejs +61 -0
- package/templates/clean-architecture/ts/src/errors/BadRequestError.spec.ts.ejs +21 -0
- package/templates/clean-architecture/ts/src/errors/BadRequestError.ts +1 -1
- package/templates/clean-architecture/ts/src/errors/NotFoundError.spec.ts.ejs +21 -0
- package/templates/clean-architecture/ts/src/errors/NotFoundError.ts +1 -1
- package/templates/clean-architecture/ts/src/index.ts.ejs +15 -11
- package/templates/clean-architecture/ts/src/infrastructure/log/logger.spec.ts.ejs +64 -0
- package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.spec.ts.ejs +85 -0
- package/templates/clean-architecture/ts/src/infrastructure/repositories/UserRepository.ts.ejs +2 -3
- package/templates/clean-architecture/ts/src/interfaces/controllers/userController.spec.ts.ejs +166 -0
- package/templates/clean-architecture/ts/src/interfaces/graphql/context.spec.ts.ejs +32 -0
- package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/user.resolvers.spec.ts.ejs +51 -0
- package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.spec.ts.ejs +40 -0
- package/templates/clean-architecture/ts/src/usecases/createUser.spec.ts.ejs +51 -0
- package/templates/clean-architecture/ts/src/usecases/getAllUsers.spec.ts.ejs +63 -0
- package/templates/clean-architecture/ts/src/utils/{error.middleware.ts.ejs → errorMiddleware.ts.ejs} +1 -2
- package/templates/common/caching/js/memoryCache.spec.js.ejs +101 -0
- package/templates/common/caching/js/redisClient.js.ejs +4 -0
- package/templates/common/caching/js/redisClient.spec.js.ejs +149 -0
- package/templates/common/caching/ts/memoryCache.spec.ts.ejs +102 -0
- package/templates/common/caching/ts/redisClient.spec.ts.ejs +157 -0
- package/templates/common/caching/ts/redisClient.ts.ejs +4 -0
- package/templates/common/database/js/database.spec.js.ejs +56 -0
- package/templates/common/database/js/models/User.js.ejs +22 -0
- package/templates/common/database/js/models/User.spec.js.ejs +84 -0
- package/templates/common/database/js/mongoose.spec.js.ejs +43 -0
- package/templates/common/database/ts/database.spec.ts.ejs +56 -0
- package/templates/common/database/ts/models/User.spec.ts.ejs +84 -0
- package/templates/common/database/ts/models/User.ts.ejs +26 -0
- package/templates/common/database/ts/mongoose.spec.ts.ejs +42 -0
- package/templates/common/eslint.config.mjs.ejs +11 -2
- package/templates/common/health/js/healthRoute.js.ejs +44 -0
- package/templates/common/health/js/healthRoute.spec.js.ejs +70 -0
- package/templates/common/health/ts/healthRoute.spec.ts.ejs +76 -0
- package/templates/common/health/ts/healthRoute.ts.ejs +43 -0
- package/templates/common/jest.config.js.ejs +19 -5
- package/templates/common/kafka/js/config/kafka.spec.js.ejs +21 -0
- package/templates/common/kafka/js/services/kafkaService.js.ejs +13 -4
- package/templates/common/kafka/js/services/kafkaService.spec.js.ejs +60 -0
- package/templates/common/kafka/ts/config/kafka.spec.ts.ejs +21 -0
- package/templates/common/kafka/ts/services/kafkaService.spec.ts.ejs +61 -0
- package/templates/common/kafka/ts/services/kafkaService.ts.ejs +6 -1
- package/templates/common/package.json.ejs +0 -3
- package/templates/common/shutdown/js/gracefulShutdown.js.ejs +61 -0
- package/templates/common/shutdown/js/gracefulShutdown.spec.js.ejs +160 -0
- package/templates/common/shutdown/ts/gracefulShutdown.spec.ts.ejs +158 -0
- package/templates/common/shutdown/ts/gracefulShutdown.ts.ejs +58 -0
- package/templates/common/src/utils/errorMiddleware.spec.js.ejs +79 -0
- package/templates/common/src/utils/errorMiddleware.spec.ts.ejs +94 -0
- package/templates/common/tsconfig.json +1 -1
- package/templates/mvc/js/src/controllers/userController.js.ejs +4 -31
- package/templates/mvc/js/src/controllers/userController.spec.js.ejs +170 -0
- package/templates/mvc/js/src/errors/BadRequestError.js +1 -1
- package/templates/mvc/js/src/errors/BadRequestError.spec.js.ejs +21 -0
- package/templates/mvc/js/src/errors/NotFoundError.js +1 -1
- package/templates/mvc/js/src/errors/NotFoundError.spec.js.ejs +21 -0
- package/templates/mvc/js/src/graphql/context.spec.js.ejs +29 -0
- package/templates/mvc/js/src/graphql/resolvers/user.resolvers.spec.js.ejs +47 -0
- package/templates/mvc/js/src/index.js.ejs +11 -9
- package/templates/mvc/js/src/routes/api.spec.js.ejs +36 -0
- package/templates/mvc/js/src/utils/logger.spec.js.ejs +63 -0
- package/templates/mvc/ts/src/controllers/userController.spec.ts.ejs +185 -0
- package/templates/mvc/ts/src/controllers/userController.ts.ejs +4 -31
- package/templates/mvc/ts/src/errors/BadRequestError.spec.ts.ejs +21 -0
- package/templates/mvc/ts/src/errors/BadRequestError.ts +1 -1
- package/templates/mvc/ts/src/errors/NotFoundError.spec.ts.ejs +21 -0
- package/templates/mvc/ts/src/errors/NotFoundError.ts +1 -1
- package/templates/mvc/ts/src/graphql/context.spec.ts.ejs +30 -0
- package/templates/mvc/ts/src/graphql/resolvers/user.resolvers.spec.ts.ejs +51 -0
- package/templates/mvc/ts/src/index.ts.ejs +13 -9
- package/templates/mvc/ts/src/routes/api.spec.ts.ejs +40 -0
- package/templates/mvc/ts/src/utils/{error.middleware.ts.ejs → errorMiddleware.ts.ejs} +1 -2
- package/templates/mvc/ts/src/utils/logger.spec.ts.ejs +64 -0
- package/docs/demo.gif +0 -0
- package/docs/generateCase.md +0 -265
- package/docs/generatorFlow.md +0 -233
- package/docs/releaseNoteRule.md +0 -42
- package/docs/ruleDevelop.md +0 -30
- package/templates/common/tests/health.test.ts.ejs +0 -14
- /package/templates/clean-architecture/js/src/infrastructure/webserver/{middlewares/error.middleware.js → middleware/errorMiddleware.js} +0 -0
- /package/templates/mvc/js/src/utils/{error.middleware.js → errorMiddleware.js} +0 -0
package/docs/generateCase.md
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
# NodeJS Quickstart Generator - Test Cases
|
|
2
|
-
|
|
3
|
-
This document lists the **240 possible project combinations** supported by the `nodejs-quickstart` CLI. These combinations cover all supported languages, architectures, databases, communication patterns, and caching options.
|
|
4
|
-
|
|
5
|
-
## Summary
|
|
6
|
-
- **CI Providers**: `None`, `GitHub Actions`, `Jenkins`, `GitLab CI`
|
|
7
|
-
- **MVC Architecture**: 180 Combinations
|
|
8
|
-
- **Clean Architecture**: 60 Combinations
|
|
9
|
-
|
|
10
|
-
**Total Core Combinations: 240**
|
|
11
|
-
|
|
12
|
-
> **Note on CI/CD**: Each combination can be generated with or without CI/CD (`--ci-provider`), effectively doubling the state space.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## 1. MVC Architecture (180 Cases)
|
|
17
|
-
|
|
18
|
-
| # | Language | Architecture | View Engine | Database | Communication | Caching |
|
|
19
|
-
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
|
20
|
-
| 1 | TypeScript | MVC | EJS | None | REST APIs | None |
|
|
21
|
-
| 2 | TypeScript | MVC | EJS | None | GraphQL | None |
|
|
22
|
-
| 3 | TypeScript | MVC | EJS | None | Kafka | None |
|
|
23
|
-
| 4 | TypeScript | MVC | EJS | MySQL | REST APIs | None |
|
|
24
|
-
| 5 | TypeScript | MVC | EJS | MySQL | REST APIs | Redis |
|
|
25
|
-
| 6 | TypeScript | MVC | EJS | MySQL | REST APIs | Memory Cache |
|
|
26
|
-
| 7 | TypeScript | MVC | EJS | MySQL | GraphQL | None |
|
|
27
|
-
| 8 | TypeScript | MVC | EJS | MySQL | GraphQL | Redis |
|
|
28
|
-
| 9 | TypeScript | MVC | EJS | MySQL | GraphQL | Memory Cache |
|
|
29
|
-
| 10 | TypeScript | MVC | EJS | MySQL | Kafka | None |
|
|
30
|
-
| 11 | TypeScript | MVC | EJS | MySQL | Kafka | Redis |
|
|
31
|
-
| 12 | TypeScript | MVC | EJS | MySQL | Kafka | Memory Cache |
|
|
32
|
-
| 13 | TypeScript | MVC | EJS | PostgreSQL | REST APIs | None |
|
|
33
|
-
| 14 | TypeScript | MVC | EJS | PostgreSQL | REST APIs | Redis |
|
|
34
|
-
| 15 | TypeScript | MVC | EJS | PostgreSQL | REST APIs | Memory Cache |
|
|
35
|
-
| 16 | TypeScript | MVC | EJS | PostgreSQL | GraphQL | None |
|
|
36
|
-
| 17 | TypeScript | MVC | EJS | PostgreSQL | GraphQL | Redis |
|
|
37
|
-
| 18 | TypeScript | MVC | EJS | PostgreSQL | GraphQL | Memory Cache |
|
|
38
|
-
| 19 | TypeScript | MVC | EJS | PostgreSQL | Kafka | None |
|
|
39
|
-
| 20 | TypeScript | MVC | EJS | PostgreSQL | Kafka | Redis |
|
|
40
|
-
| 21 | TypeScript | MVC | EJS | PostgreSQL | Kafka | Memory Cache |
|
|
41
|
-
| 22 | TypeScript | MVC | EJS | MongoDB | REST APIs | None |
|
|
42
|
-
| 23 | TypeScript | MVC | EJS | MongoDB | REST APIs | Redis |
|
|
43
|
-
| 24 | TypeScript | MVC | EJS | MongoDB | REST APIs | Memory Cache |
|
|
44
|
-
| 25 | TypeScript | MVC | EJS | MongoDB | GraphQL | None |
|
|
45
|
-
| 26 | TypeScript | MVC | EJS | MongoDB | GraphQL | Redis |
|
|
46
|
-
| 27 | TypeScript | MVC | EJS | MongoDB | GraphQL | Memory Cache |
|
|
47
|
-
| 28 | TypeScript | MVC | EJS | MongoDB | Kafka | None |
|
|
48
|
-
| 29 | TypeScript | MVC | EJS | MongoDB | Kafka | Redis |
|
|
49
|
-
| 30 | TypeScript | MVC | EJS | MongoDB | Kafka | Memory Cache |
|
|
50
|
-
| 31 | TypeScript | MVC | Pug | None | REST APIs | None |
|
|
51
|
-
| 32 | TypeScript | MVC | Pug | None | GraphQL | None |
|
|
52
|
-
| 33 | TypeScript | MVC | Pug | None | Kafka | None |
|
|
53
|
-
| 34 | TypeScript | MVC | Pug | MySQL | REST APIs | None |
|
|
54
|
-
| 35 | TypeScript | MVC | Pug | MySQL | REST APIs | Redis |
|
|
55
|
-
| 36 | TypeScript | MVC | Pug | MySQL | REST APIs | Memory Cache |
|
|
56
|
-
| 37 | TypeScript | MVC | Pug | MySQL | GraphQL | None |
|
|
57
|
-
| 38 | TypeScript | MVC | Pug | MySQL | GraphQL | Redis |
|
|
58
|
-
| 39 | TypeScript | MVC | Pug | MySQL | GraphQL | Memory Cache |
|
|
59
|
-
| 40 | TypeScript | MVC | Pug | MySQL | Kafka | None |
|
|
60
|
-
| 41 | TypeScript | MVC | Pug | MySQL | Kafka | Redis |
|
|
61
|
-
| 42 | TypeScript | MVC | Pug | MySQL | Kafka | Memory Cache |
|
|
62
|
-
| 43 | TypeScript | MVC | Pug | PostgreSQL | REST APIs | None |
|
|
63
|
-
| 44 | TypeScript | MVC | Pug | PostgreSQL | REST APIs | Redis |
|
|
64
|
-
| 45 | TypeScript | MVC | Pug | PostgreSQL | REST APIs | Memory Cache |
|
|
65
|
-
| 46 | TypeScript | MVC | Pug | PostgreSQL | GraphQL | None |
|
|
66
|
-
| 47 | TypeScript | MVC | Pug | PostgreSQL | GraphQL | Redis |
|
|
67
|
-
| 48 | TypeScript | MVC | Pug | PostgreSQL | GraphQL | Memory Cache |
|
|
68
|
-
| 49 | TypeScript | MVC | Pug | PostgreSQL | Kafka | None |
|
|
69
|
-
| 50 | TypeScript | MVC | Pug | PostgreSQL | Kafka | Redis |
|
|
70
|
-
| 51 | TypeScript | MVC | Pug | PostgreSQL | Kafka | Memory Cache |
|
|
71
|
-
| 52 | TypeScript | MVC | Pug | MongoDB | REST APIs | None |
|
|
72
|
-
| 53 | TypeScript | MVC | Pug | MongoDB | REST APIs | Redis |
|
|
73
|
-
| 54 | TypeScript | MVC | Pug | MongoDB | REST APIs | Memory Cache |
|
|
74
|
-
| 55 | TypeScript | MVC | Pug | MongoDB | GraphQL | None |
|
|
75
|
-
| 56 | TypeScript | MVC | Pug | MongoDB | GraphQL | Redis |
|
|
76
|
-
| 57 | TypeScript | MVC | Pug | MongoDB | GraphQL | Memory Cache |
|
|
77
|
-
| 58 | TypeScript | MVC | Pug | MongoDB | Kafka | None |
|
|
78
|
-
| 59 | TypeScript | MVC | Pug | MongoDB | Kafka | Redis |
|
|
79
|
-
| 60 | TypeScript | MVC | Pug | MongoDB | Kafka | Memory Cache |
|
|
80
|
-
| 61 | TypeScript | MVC | None | None | REST APIs | None |
|
|
81
|
-
| 62 | TypeScript | MVC | None | None | GraphQL | None |
|
|
82
|
-
| 63 | TypeScript | MVC | None | None | Kafka | None |
|
|
83
|
-
| 64 | TypeScript | MVC | None | MySQL | REST APIs | None |
|
|
84
|
-
| 65 | TypeScript | MVC | None | MySQL | REST APIs | Redis |
|
|
85
|
-
| 66 | TypeScript | MVC | None | MySQL | REST APIs | Memory Cache |
|
|
86
|
-
| 67 | TypeScript | MVC | None | MySQL | GraphQL | None |
|
|
87
|
-
| 68 | TypeScript | MVC | None | MySQL | GraphQL | Redis |
|
|
88
|
-
| 69 | TypeScript | MVC | None | MySQL | GraphQL | Memory Cache |
|
|
89
|
-
| 70 | TypeScript | MVC | None | MySQL | Kafka | None |
|
|
90
|
-
| 71 | TypeScript | MVC | None | MySQL | Kafka | Redis |
|
|
91
|
-
| 72 | TypeScript | MVC | None | MySQL | Kafka | Memory Cache |
|
|
92
|
-
| 73 | TypeScript | MVC | None | PostgreSQL | REST APIs | None |
|
|
93
|
-
| 74 | TypeScript | MVC | None | PostgreSQL | REST APIs | Redis |
|
|
94
|
-
| 75 | TypeScript | MVC | None | PostgreSQL | REST APIs | Memory Cache |
|
|
95
|
-
| 76 | TypeScript | MVC | None | PostgreSQL | GraphQL | None |
|
|
96
|
-
| 77 | TypeScript | MVC | None | PostgreSQL | GraphQL | Redis |
|
|
97
|
-
| 78 | TypeScript | MVC | None | PostgreSQL | GraphQL | Memory Cache |
|
|
98
|
-
| 79 | TypeScript | MVC | None | PostgreSQL | Kafka | None |
|
|
99
|
-
| 80 | TypeScript | MVC | None | PostgreSQL | Kafka | Redis |
|
|
100
|
-
| 81 | TypeScript | MVC | None | PostgreSQL | Kafka | Memory Cache |
|
|
101
|
-
| 82 | TypeScript | MVC | None | MongoDB | REST APIs | None |
|
|
102
|
-
| 83 | TypeScript | MVC | None | MongoDB | REST APIs | Redis |
|
|
103
|
-
| 84 | TypeScript | MVC | None | MongoDB | REST APIs | Memory Cache |
|
|
104
|
-
| 85 | TypeScript | MVC | None | MongoDB | GraphQL | None |
|
|
105
|
-
| 86 | TypeScript | MVC | None | MongoDB | GraphQL | Redis |
|
|
106
|
-
| 87 | TypeScript | MVC | None | MongoDB | GraphQL | Memory Cache |
|
|
107
|
-
| 88 | TypeScript | MVC | None | MongoDB | Kafka | None |
|
|
108
|
-
| 89 | TypeScript | MVC | None | MongoDB | Kafka | Redis |
|
|
109
|
-
| 90 | TypeScript | MVC | None | MongoDB | Kafka | Memory Cache |
|
|
110
|
-
| 91 | JavaScript | MVC | EJS | None | REST APIs | None |
|
|
111
|
-
| 92 | JavaScript | MVC | EJS | None | GraphQL | None |
|
|
112
|
-
| 93 | JavaScript | MVC | EJS | None | Kafka | None |
|
|
113
|
-
| 94 | JavaScript | MVC | EJS | MySQL | REST APIs | None |
|
|
114
|
-
| 95 | JavaScript | MVC | EJS | MySQL | REST APIs | Redis |
|
|
115
|
-
| 96 | JavaScript | MVC | EJS | MySQL | REST APIs | Memory Cache |
|
|
116
|
-
| 97 | JavaScript | MVC | EJS | MySQL | GraphQL | None |
|
|
117
|
-
| 98 | JavaScript | MVC | EJS | MySQL | GraphQL | Redis |
|
|
118
|
-
| 99 | JavaScript | MVC | EJS | MySQL | GraphQL | Memory Cache |
|
|
119
|
-
| 100 | JavaScript | MVC | EJS | MySQL | Kafka | None |
|
|
120
|
-
| 101 | JavaScript | MVC | EJS | MySQL | Kafka | Redis |
|
|
121
|
-
| 102 | JavaScript | MVC | EJS | MySQL | Kafka | Memory Cache |
|
|
122
|
-
| 103 | JavaScript | MVC | EJS | PostgreSQL | REST APIs | None |
|
|
123
|
-
| 104 | JavaScript | MVC | EJS | PostgreSQL | REST APIs | Redis |
|
|
124
|
-
| 105 | JavaScript | MVC | EJS | PostgreSQL | REST APIs | Memory Cache |
|
|
125
|
-
| 106 | JavaScript | MVC | EJS | PostgreSQL | GraphQL | None |
|
|
126
|
-
| 107 | JavaScript | MVC | EJS | PostgreSQL | GraphQL | Redis |
|
|
127
|
-
| 108 | JavaScript | MVC | EJS | PostgreSQL | GraphQL | Memory Cache |
|
|
128
|
-
| 109 | JavaScript | MVC | EJS | PostgreSQL | Kafka | None |
|
|
129
|
-
| 110 | JavaScript | MVC | EJS | PostgreSQL | Kafka | Redis |
|
|
130
|
-
| 111 | JavaScript | MVC | EJS | PostgreSQL | Kafka | Memory Cache |
|
|
131
|
-
| 112 | JavaScript | MVC | EJS | MongoDB | REST APIs | None |
|
|
132
|
-
| 113 | JavaScript | MVC | EJS | MongoDB | REST APIs | Redis |
|
|
133
|
-
| 114 | JavaScript | MVC | EJS | MongoDB | REST APIs | Memory Cache |
|
|
134
|
-
| 115 | JavaScript | MVC | EJS | MongoDB | GraphQL | None |
|
|
135
|
-
| 116 | JavaScript | MVC | EJS | MongoDB | GraphQL | Redis |
|
|
136
|
-
| 117 | JavaScript | MVC | EJS | MongoDB | GraphQL | Memory Cache |
|
|
137
|
-
| 118 | JavaScript | MVC | EJS | MongoDB | Kafka | None |
|
|
138
|
-
| 119 | JavaScript | MVC | EJS | MongoDB | Kafka | Redis |
|
|
139
|
-
| 120 | JavaScript | MVC | EJS | MongoDB | Kafka | Memory Cache |
|
|
140
|
-
| 121 | JavaScript | MVC | Pug | None | REST APIs | None |
|
|
141
|
-
| 122 | JavaScript | MVC | Pug | None | GraphQL | None |
|
|
142
|
-
| 123 | JavaScript | MVC | Pug | None | Kafka | None |
|
|
143
|
-
| 124 | JavaScript | MVC | Pug | MySQL | REST APIs | None |
|
|
144
|
-
| 125 | JavaScript | MVC | Pug | MySQL | REST APIs | Redis |
|
|
145
|
-
| 126 | JavaScript | MVC | Pug | MySQL | REST APIs | Memory Cache |
|
|
146
|
-
| 127 | JavaScript | MVC | Pug | MySQL | GraphQL | None |
|
|
147
|
-
| 128 | JavaScript | MVC | Pug | MySQL | GraphQL | Redis |
|
|
148
|
-
| 129 | JavaScript | MVC | Pug | MySQL | GraphQL | Memory Cache |
|
|
149
|
-
| 130 | JavaScript | MVC | Pug | MySQL | Kafka | None |
|
|
150
|
-
| 131 | JavaScript | MVC | Pug | MySQL | Kafka | Redis |
|
|
151
|
-
| 132 | JavaScript | MVC | Pug | MySQL | Kafka | Memory Cache |
|
|
152
|
-
| 133 | JavaScript | MVC | Pug | PostgreSQL | REST APIs | None |
|
|
153
|
-
| 134 | JavaScript | MVC | Pug | PostgreSQL | REST APIs | Redis |
|
|
154
|
-
| 135 | JavaScript | MVC | Pug | PostgreSQL | REST APIs | Memory Cache |
|
|
155
|
-
| 136 | JavaScript | MVC | Pug | PostgreSQL | GraphQL | None |
|
|
156
|
-
| 137 | JavaScript | MVC | Pug | PostgreSQL | GraphQL | Redis |
|
|
157
|
-
| 138 | JavaScript | MVC | Pug | PostgreSQL | GraphQL | Memory Cache |
|
|
158
|
-
| 139 | JavaScript | MVC | Pug | PostgreSQL | Kafka | None |
|
|
159
|
-
| 140 | JavaScript | MVC | Pug | PostgreSQL | Kafka | Redis |
|
|
160
|
-
| 141 | JavaScript | MVC | Pug | PostgreSQL | Kafka | Memory Cache |
|
|
161
|
-
| 142 | JavaScript | MVC | Pug | MongoDB | REST APIs | None |
|
|
162
|
-
| 143 | JavaScript | MVC | Pug | MongoDB | REST APIs | Redis |
|
|
163
|
-
| 144 | JavaScript | MVC | Pug | MongoDB | REST APIs | Memory Cache |
|
|
164
|
-
| 145 | JavaScript | MVC | Pug | MongoDB | GraphQL | None |
|
|
165
|
-
| 146 | JavaScript | MVC | Pug | MongoDB | GraphQL | Redis |
|
|
166
|
-
| 147 | JavaScript | MVC | Pug | MongoDB | GraphQL | Memory Cache |
|
|
167
|
-
| 148 | JavaScript | MVC | Pug | MongoDB | Kafka | None |
|
|
168
|
-
| 149 | JavaScript | MVC | Pug | MongoDB | Kafka | Redis |
|
|
169
|
-
| 150 | JavaScript | MVC | Pug | MongoDB | Kafka | Memory Cache |
|
|
170
|
-
| 151 | JavaScript | MVC | None | None | REST APIs | None |
|
|
171
|
-
| 152 | JavaScript | MVC | None | None | GraphQL | None |
|
|
172
|
-
| 153 | JavaScript | MVC | None | None | Kafka | None |
|
|
173
|
-
| 154 | JavaScript | MVC | None | MySQL | REST APIs | None |
|
|
174
|
-
| 155 | JavaScript | MVC | None | MySQL | REST APIs | Redis |
|
|
175
|
-
| 156 | JavaScript | MVC | None | MySQL | REST APIs | Memory Cache |
|
|
176
|
-
| 157 | JavaScript | MVC | None | MySQL | GraphQL | None |
|
|
177
|
-
| 158 | JavaScript | MVC | None | MySQL | GraphQL | Redis |
|
|
178
|
-
| 159 | JavaScript | MVC | None | MySQL | GraphQL | Memory Cache |
|
|
179
|
-
| 160 | JavaScript | MVC | None | MySQL | Kafka | None |
|
|
180
|
-
| 161 | JavaScript | MVC | None | MySQL | Kafka | Redis |
|
|
181
|
-
| 162 | JavaScript | MVC | None | MySQL | Kafka | Memory Cache |
|
|
182
|
-
| 163 | JavaScript | MVC | None | PostgreSQL | REST APIs | None |
|
|
183
|
-
| 164 | JavaScript | MVC | None | PostgreSQL | REST APIs | Redis |
|
|
184
|
-
| 165 | JavaScript | MVC | None | PostgreSQL | REST APIs | Memory Cache |
|
|
185
|
-
| 166 | JavaScript | MVC | None | PostgreSQL | GraphQL | None |
|
|
186
|
-
| 167 | JavaScript | MVC | None | PostgreSQL | GraphQL | Redis |
|
|
187
|
-
| 168 | JavaScript | MVC | None | PostgreSQL | GraphQL | Memory Cache |
|
|
188
|
-
| 169 | JavaScript | MVC | None | PostgreSQL | Kafka | None |
|
|
189
|
-
| 170 | JavaScript | MVC | None | PostgreSQL | Kafka | Redis |
|
|
190
|
-
| 171 | JavaScript | MVC | None | PostgreSQL | Kafka | Memory Cache |
|
|
191
|
-
| 172 | JavaScript | MVC | None | MongoDB | REST APIs | None |
|
|
192
|
-
| 173 | JavaScript | MVC | None | MongoDB | REST APIs | Redis |
|
|
193
|
-
| 174 | JavaScript | MVC | None | MongoDB | REST APIs | Memory Cache |
|
|
194
|
-
| 175 | JavaScript | MVC | None | MongoDB | GraphQL | None |
|
|
195
|
-
| 176 | JavaScript | MVC | None | MongoDB | GraphQL | Redis |
|
|
196
|
-
| 177 | JavaScript | MVC | None | MongoDB | GraphQL | Memory Cache |
|
|
197
|
-
| 178 | JavaScript | MVC | None | MongoDB | Kafka | None |
|
|
198
|
-
| 179 | JavaScript | MVC | None | MongoDB | Kafka | Redis |
|
|
199
|
-
| 180 | JavaScript | MVC | None | MongoDB | Kafka | Memory Cache |
|
|
200
|
-
|
|
201
|
-
## 2. Clean Architecture (60 Cases)
|
|
202
|
-
*Note: Clean Architecture does not use server-side view engines (EJS/Pug).*
|
|
203
|
-
|
|
204
|
-
| # | Language | Architecture | View Engine | Database | Communication | Caching |
|
|
205
|
-
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
|
|
206
|
-
| 181 | TypeScript | Clean Architecture | N/A | None | REST APIs | None |
|
|
207
|
-
| 182 | TypeScript | Clean Architecture | N/A | None | GraphQL | None |
|
|
208
|
-
| 183 | TypeScript | Clean Architecture | N/A | None | Kafka | None |
|
|
209
|
-
| 184 | TypeScript | Clean Architecture | N/A | MySQL | REST APIs | None |
|
|
210
|
-
| 185 | TypeScript | Clean Architecture | N/A | MySQL | REST APIs | Redis |
|
|
211
|
-
| 186 | TypeScript | Clean Architecture | N/A | MySQL | REST APIs | Memory Cache |
|
|
212
|
-
| 187 | TypeScript | Clean Architecture | N/A | MySQL | GraphQL | None |
|
|
213
|
-
| 188 | TypeScript | Clean Architecture | N/A | MySQL | GraphQL | Redis |
|
|
214
|
-
| 189 | TypeScript | Clean Architecture | N/A | MySQL | GraphQL | Memory Cache |
|
|
215
|
-
| 190 | TypeScript | Clean Architecture | N/A | MySQL | Kafka | None |
|
|
216
|
-
| 191 | TypeScript | Clean Architecture | N/A | MySQL | Kafka | Redis |
|
|
217
|
-
| 192 | TypeScript | Clean Architecture | N/A | MySQL | Kafka | Memory Cache |
|
|
218
|
-
| 193 | TypeScript | Clean Architecture | N/A | PostgreSQL | REST APIs | None |
|
|
219
|
-
| 194 | TypeScript | Clean Architecture | N/A | PostgreSQL | REST APIs | Redis |
|
|
220
|
-
| 195 | TypeScript | Clean Architecture | N/A | PostgreSQL | REST APIs | Memory Cache |
|
|
221
|
-
| 196 | TypeScript | Clean Architecture | N/A | PostgreSQL | GraphQL | None |
|
|
222
|
-
| 197 | TypeScript | Clean Architecture | N/A | PostgreSQL | GraphQL | Redis |
|
|
223
|
-
| 198 | TypeScript | Clean Architecture | N/A | PostgreSQL | GraphQL | Memory Cache |
|
|
224
|
-
| 199 | TypeScript | Clean Architecture | N/A | PostgreSQL | Kafka | None |
|
|
225
|
-
| 200 | TypeScript | Clean Architecture | N/A | PostgreSQL | Kafka | Redis |
|
|
226
|
-
| 201 | TypeScript | Clean Architecture | N/A | PostgreSQL | Kafka | Memory Cache |
|
|
227
|
-
| 202 | TypeScript | Clean Architecture | N/A | MongoDB | REST APIs | None |
|
|
228
|
-
| 203 | TypeScript | Clean Architecture | N/A | MongoDB | REST APIs | Redis |
|
|
229
|
-
| 204 | TypeScript | Clean Architecture | N/A | MongoDB | REST APIs | Memory Cache |
|
|
230
|
-
| 205 | TypeScript | Clean Architecture | N/A | MongoDB | GraphQL | None |
|
|
231
|
-
| 206 | TypeScript | Clean Architecture | N/A | MongoDB | GraphQL | Redis |
|
|
232
|
-
| 207 | TypeScript | Clean Architecture | N/A | MongoDB | GraphQL | Memory Cache |
|
|
233
|
-
| 208 | TypeScript | Clean Architecture | N/A | MongoDB | Kafka | None |
|
|
234
|
-
| 209 | TypeScript | Clean Architecture | N/A | MongoDB | Kafka | Redis |
|
|
235
|
-
| 210 | TypeScript | Clean Architecture | N/A | MongoDB | Kafka | Memory Cache |
|
|
236
|
-
| 211 | JavaScript | Clean Architecture | N/A | None | REST APIs | None |
|
|
237
|
-
| 212 | JavaScript | Clean Architecture | N/A | None | GraphQL | None |
|
|
238
|
-
| 213 | JavaScript | Clean Architecture | N/A | None | Kafka | None |
|
|
239
|
-
| 214 | JavaScript | Clean Architecture | N/A | MySQL | REST APIs | None |
|
|
240
|
-
| 215 | JavaScript | Clean Architecture | N/A | MySQL | REST APIs | Redis |
|
|
241
|
-
| 216 | JavaScript | Clean Architecture | N/A | MySQL | REST APIs | Memory Cache |
|
|
242
|
-
| 217 | JavaScript | Clean Architecture | N/A | MySQL | GraphQL | None |
|
|
243
|
-
| 218 | JavaScript | Clean Architecture | N/A | MySQL | GraphQL | Redis |
|
|
244
|
-
| 219 | JavaScript | Clean Architecture | N/A | MySQL | GraphQL | Memory Cache |
|
|
245
|
-
| 220 | JavaScript | Clean Architecture | N/A | MySQL | Kafka | None |
|
|
246
|
-
| 221 | JavaScript | Clean Architecture | N/A | MySQL | Kafka | Redis |
|
|
247
|
-
| 222 | JavaScript | Clean Architecture | N/A | MySQL | Kafka | Memory Cache |
|
|
248
|
-
| 223 | JavaScript | Clean Architecture | N/A | PostgreSQL | REST APIs | None |
|
|
249
|
-
| 224 | JavaScript | Clean Architecture | N/A | PostgreSQL | REST APIs | Redis |
|
|
250
|
-
| 225 | JavaScript | Clean Architecture | N/A | PostgreSQL | REST APIs | Memory Cache |
|
|
251
|
-
| 226 | JavaScript | Clean Architecture | N/A | PostgreSQL | GraphQL | None |
|
|
252
|
-
| 227 | JavaScript | Clean Architecture | N/A | PostgreSQL | GraphQL | Redis |
|
|
253
|
-
| 228 | JavaScript | Clean Architecture | N/A | PostgreSQL | GraphQL | Memory Cache |
|
|
254
|
-
| 229 | JavaScript | Clean Architecture | N/A | PostgreSQL | Kafka | None |
|
|
255
|
-
| 230 | JavaScript | Clean Architecture | N/A | PostgreSQL | Kafka | Redis |
|
|
256
|
-
| 231 | JavaScript | Clean Architecture | N/A | PostgreSQL | Kafka | Memory Cache |
|
|
257
|
-
| 232 | JavaScript | Clean Architecture | N/A | MongoDB | REST APIs | None |
|
|
258
|
-
| 233 | JavaScript | Clean Architecture | N/A | MongoDB | REST APIs | Redis |
|
|
259
|
-
| 234 | JavaScript | Clean Architecture | N/A | MongoDB | REST APIs | Memory Cache |
|
|
260
|
-
| 235 | JavaScript | Clean Architecture | N/A | MongoDB | GraphQL | None |
|
|
261
|
-
| 236 | JavaScript | Clean Architecture | N/A | MongoDB | GraphQL | Redis |
|
|
262
|
-
| 237 | JavaScript | Clean Architecture | N/A | MongoDB | GraphQL | Memory Cache |
|
|
263
|
-
| 238 | JavaScript | Clean Architecture | N/A | MongoDB | Kafka | None |
|
|
264
|
-
| 239 | JavaScript | Clean Architecture | N/A | MongoDB | Kafka | Redis |
|
|
265
|
-
| 240 | JavaScript | Clean Architecture | N/A | MongoDB | Kafka | Memory Cache |
|
package/docs/generatorFlow.md
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
# Generator Flow Documentation
|
|
2
|
-
|
|
3
|
-
This document outlines the internal flow of the `nodejs-quickstart-structure` generator, including user options, the step-by-step generation process, and the resulting codebase structures.
|
|
4
|
-
|
|
5
|
-
## 1. Technologies Used
|
|
6
|
-
|
|
7
|
-
The `nodejs-quickstart-structure` CLI is built using the following key technologies:
|
|
8
|
-
|
|
9
|
-
* **[Node.js](https://nodejs.org/)**: The runtime environment.
|
|
10
|
-
* **[Commander.js](https://github.com/tj/commander.js)** (`^13.1.0`): For parsing command-line arguments and options.
|
|
11
|
-
* **[Inquirer.js](https://github.com/SBoudrias/Inquirer.js)** (`^12.4.1`): For interactive command-line user interface (prompts).
|
|
12
|
-
* **[Chalk](https://github.com/chalk/chalk)** (`^5.4.1`): For terminal string styling (color output).
|
|
13
|
-
* **[EJS (Embedded JavaScript templates)](https://github.com/mde/ejs)** (`^3.1.10`): For templating files (dynamic content generation).
|
|
14
|
-
* **[fs-extra](https://github.com/jprichardson/node-fs-extra)** (`^11.3.0`): For enhanced file system methods (copy, ensureDir, etc.).
|
|
15
|
-
|
|
16
|
-
## 2. User Choices (Cases)
|
|
17
|
-
|
|
18
|
-
The generator prompts the user for the following configurations. These determine the logic and structure of the generated project.
|
|
19
|
-
|
|
20
|
-
| Option | Choices | Default | Description |
|
|
21
|
-
| :--- | :--- | :--- | :--- |
|
|
22
|
-
| **Project Name** | Input String | `nodejs-service` | Name of the project directory. |
|
|
23
|
-
| **Language** | `JavaScript`, `TypeScript` | `TypeScript` | The programming language to use. |
|
|
24
|
-
| **Architecture** | `MVC`, `Clean Architecture` | `MVC` | The architectural pattern. |
|
|
25
|
-
| **View Engine** | `None`, `EJS`, `Pug` | `None` | (MVC Only) Template engine for server-side rendering. |
|
|
26
|
-
| **Database** | `None`, `MySQL`, `PostgreSQL`, `MongoDB` | `None` | The primary database. |
|
|
27
|
-
| **Database Name** | Input String | `demo` | The name of the database to use/create. |
|
|
28
|
-
| **Communication**| `REST APIs`, `GraphQL`, `Kafka` | `REST APIs` | The primary communication method. |
|
|
29
|
-
| **Caching Layer**| `None`, `Redis`, `Memory Cache` | `None` | (If DB selected) Caching solution. |
|
|
30
|
-
| **CI/CD Provider**| `None`, `GitHub Actions`, `Jenkins`| `None` | Setup for Continuous Integration/Deployment. |
|
|
31
|
-
|
|
32
|
-
## 3. Main Generator Flow
|
|
33
|
-
|
|
34
|
-
The `generateProject` function in `lib/generator.js` executes the following steps:
|
|
35
|
-
|
|
36
|
-
1. **Create Project Directory**: Ensures the directory does not already exist and creates it.
|
|
37
|
-
2. **Select & Copy Base Structure**:
|
|
38
|
-
* Based on **Architecture** (`mvc`/`clean-architecture`) and **Language** (`js`/`ts`), it selects the appropriate template from `templates/{arch}/{lang}`.
|
|
39
|
-
* Copies the entire base template to the target directory.
|
|
40
|
-
3. **Render `package.json`**:
|
|
41
|
-
* Uses `templates/common/package.json.ejs`.
|
|
42
|
-
* Injects dependencies based on User Choices (DB drivers, view engines, etc.).
|
|
43
|
-
4. **Render `docker-compose.yml`**:
|
|
44
|
-
* Uses `templates/common/docker-compose.yml.ejs`.
|
|
45
|
-
* Configures services (DB, Zookeeper/Kafka) based on selection.
|
|
46
|
-
* **Note**: If Database is `None`, DB services are excluded.
|
|
47
|
-
5. **Render `README.md`**:
|
|
48
|
-
* Generates custom documentation specific to the selected stack.
|
|
49
|
-
6. **Render `src/index.{js|ts}`**:
|
|
50
|
-
* Processes the entry point file to wire up the selected DB, Architecture, and Communication type.
|
|
51
|
-
* **GraphQL**: Wires up Apollo Server middleware with `formatError` hook for centralized error handling.
|
|
52
|
-
* **REST APIs / Kafka**: Registers `app.use(errorMiddleware)` at the end of the Express chain.
|
|
53
|
-
7. **Render Error Middleware** (`renderErrorMiddleware`):
|
|
54
|
-
* Processes `error.middleware.{ts|js}.ejs` template from the target directory's `src/utils/` path.
|
|
55
|
-
* Renders to `src/utils/error.middleware.{ts|js}` in the generated project.
|
|
56
|
-
* **Clean Architecture**: Also handles `src/infrastructure/webserver/middlewares/error.middleware.{js}` path.
|
|
57
|
-
8. **Dynamic Component Generation**:
|
|
58
|
-
* **MVC**: Generates `userController` (imports specific DB service, uses `next(error)`).
|
|
59
|
-
* **Clean Architecture**: Generates `UserRepository` (infrastructure layer implementation).
|
|
60
|
-
* **Clean Architecture (JS only)**: Generates `server.js` (webserver setup).
|
|
61
|
-
9. **Communication Setup**:
|
|
62
|
-
* **GraphQL**:
|
|
63
|
-
* Generates Apollo Server v4 schema (`typeDefs`) and resolvers.
|
|
64
|
-
* Configures `formatError` hook with `unwrapResolverError` for structured error mapping.
|
|
65
|
-
* Automatically embeds Apollo Sandbox with local CSP headers (no CDN dependency).
|
|
66
|
-
* **Kafka**:
|
|
67
|
-
* Copies Kafka client/service templates.
|
|
68
|
-
* **Clean Architecture Restructuring**:
|
|
69
|
-
* Moves service to `src/infrastructure/messaging`.
|
|
70
|
-
* Moves config to `src/infrastructure/config`.
|
|
71
|
-
* Removes REST-specific folders (`interfaces/routes`, `interfaces/controllers`).
|
|
72
|
-
* **MVC Cleanup**:
|
|
73
|
-
* If no View Engine is selected, removes `src/controllers` and `src/routes` (assumes pure worker).
|
|
74
|
-
10. **Common Configuration**:
|
|
75
|
-
* Copies `.gitignore`, `.dockerignore`, `Dockerfile`.
|
|
76
|
-
* Copies `tsconfig.json` (if TypeScript).
|
|
77
|
-
11. **Database Setup**:
|
|
78
|
-
* **MongoDB**: Sets up `migrate-mongo-config.js` and initial migration script.
|
|
79
|
-
* **SQL (MySQL/Postgres)**: Sets up `flyway/sql` directory and copies initial SQL migration files.
|
|
80
|
-
* **None**: Skips migration setup.
|
|
81
|
-
12. **Caching Setup**:
|
|
82
|
-
* **Redis**:
|
|
83
|
-
* Injects `ioredis` dependency into `package.json`.
|
|
84
|
-
* Generates `redisClient.{js|ts}` config.
|
|
85
|
-
* **MVC**: Injects generic caching logic into `userController`.
|
|
86
|
-
* **Clean Architecture**: Overwrites UseCases with caching-enabled versions.
|
|
87
|
-
* **Memory Cache**:
|
|
88
|
-
* Injects `node-cache` dependency.
|
|
89
|
-
* Generates `memoryCache.{js|ts}` config.
|
|
90
|
-
* **MVC/Clean**: Consumes the generic abstraction injected above.
|
|
91
|
-
13. **Database Connection Config**:
|
|
92
|
-
* Renders `database.{js|ts}` or `mongoose.{js|ts}` based on DB selection.
|
|
93
|
-
* Places it in `src/config` (MVC) or `src/infrastructure/database` (Clean Arch).
|
|
94
|
-
* **None**: Skips this step.
|
|
95
|
-
14. **Model Generation**:
|
|
96
|
-
* Renders `User` model (Mongoose schema or Sequelize/TypeORM model) in the appropriate directory.
|
|
97
|
-
* **None**: Generates a simple Mock Entity/Model class with in-memory data for testing.
|
|
98
|
-
15. **View Engine Setup (MVC)**:
|
|
99
|
-
* If selected, copies views (`views/ejs` or `views/pug`) and `public` assets.
|
|
100
|
-
16. **Swagger Config** (`renderSwaggerConfig`):
|
|
101
|
-
* If **REST APIs** is selected, generates `swagger.yml` and `swagger.{ts|js}` config.
|
|
102
|
-
* Cleans up `.ejs` template copies for non-REST configs (GraphQL, Kafka).
|
|
103
|
-
17. **Code Quality Setup**:
|
|
104
|
-
* Generates `.eslintrc.json`, `.prettierrc`, `.lintstagedrc`.
|
|
105
|
-
18. **Test Setup**:
|
|
106
|
-
* Generates `jest.config.js` and a sample `health.test.{js|ts}`.
|
|
107
|
-
19. **CI/CD Setup**:
|
|
108
|
-
* Helper: `setupCiCd`
|
|
109
|
-
* Checks `config.ciProvider`:
|
|
110
|
-
* **GitHub Actions**: Copies `.github/workflows/ci.yml`.
|
|
111
|
-
* **Jenkins**: Renders `Jenkinsfile`.
|
|
112
|
-
* **GitLab CI**: Renders `.gitlab-ci.yml` if selected.
|
|
113
|
-
|
|
114
|
-
## 4. TypeScript vs JavaScript Generation Steps
|
|
115
|
-
|
|
116
|
-
The logic handles language differences via conditional checks and file extensions (`langExt` variable).
|
|
117
|
-
|
|
118
|
-
| Step | JavaScript (`js`) | TypeScript (`ts`) |
|
|
119
|
-
| :--- | :--- | :--- |
|
|
120
|
-
| **Base Template** | `templates/{arch}/js` | `templates/{arch}/ts` |
|
|
121
|
-
| **Entry Point** | `src/index.js` | `src/index.ts` |
|
|
122
|
-
| **tsconfig.json** | Skipped | Copied from `templates/common/tsconfig.json` |
|
|
123
|
-
| **Linting** | Standard JS config | TS-specific parser and plugins in `.eslintrc` |
|
|
124
|
-
| **Database Config** | `mongoose.js` / `database.js` | `mongoose.ts` / `database.ts` |
|
|
125
|
-
| **Models/Controllers**| `.js` extension | `.ts` extension |
|
|
126
|
-
| **Build Step** | No compilation needed | Compilation typically handled by `tsc` or `ts-node` in dev |
|
|
127
|
-
|
|
128
|
-
## 5. Possible Codebase Structures
|
|
129
|
-
|
|
130
|
-
The final structure depends heavily on **Architecture**, **Communication**, and **View Engine**.
|
|
131
|
-
|
|
132
|
-
### Case A: MVC (REST API)
|
|
133
|
-
Standard architecture for web APIs.
|
|
134
|
-
|
|
135
|
-
```text
|
|
136
|
-
project-name/
|
|
137
|
-
├── src/
|
|
138
|
-
│ ├── config/ # Database, Redis, Swagger, etc.
|
|
139
|
-
│ ├── controllers/ # Request handlers (use next(error))
|
|
140
|
-
│ ├── errors/ # ApiError, NotFoundError, BadRequestError
|
|
141
|
-
│ ├── models/ # Database models
|
|
142
|
-
│ ├── routes/ # Express routes
|
|
143
|
-
│ ├── utils/
|
|
144
|
-
│ │ ├── error.middleware.{ts|js} # Global error handler
|
|
145
|
-
│ │ ├── logger.{ts|js}
|
|
146
|
-
│ │ └── httpCodes.{ts|js}
|
|
147
|
-
│ └── index.js|ts # Entry point (registers errorMiddleware last)
|
|
148
|
-
├── tests/ # Jest tests
|
|
149
|
-
├── package.json
|
|
150
|
-
├── Dockerfile
|
|
151
|
-
└── docker-compose.yml
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Case A2: MVC (GraphQL)
|
|
155
|
-
Apollo Server v4 mounted as Express middleware.
|
|
156
|
-
|
|
157
|
-
```text
|
|
158
|
-
project-name/
|
|
159
|
-
├── src/
|
|
160
|
-
│ ├── config/ # Database, Redis config
|
|
161
|
-
│ ├── controllers/ # GraphQL resolver backing logic (throws errors)
|
|
162
|
-
│ ├── errors/ # ApiError, NotFoundError, BadRequestError
|
|
163
|
-
│ ├── graphql/
|
|
164
|
-
│ │ ├── schema/ # typeDefs
|
|
165
|
-
│ │ └── resolvers/ # user.resolvers (calls controllers, throws errors)
|
|
166
|
-
│ ├── models/
|
|
167
|
-
│ ├── utils/
|
|
168
|
-
│ │ ├── error.middleware.{ts|js} # Express-level fallback error handler
|
|
169
|
-
│ │ └── logger.{ts|js}
|
|
170
|
-
│ └── index.js|ts # Apollo Server + formatError hook
|
|
171
|
-
└── ...
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Case B: MVC (Web App with Views)
|
|
175
|
-
Includes frontend views rendered on the server.
|
|
176
|
-
|
|
177
|
-
```text
|
|
178
|
-
project-name/
|
|
179
|
-
├── public/ # CSS, JS, Images
|
|
180
|
-
├── src/
|
|
181
|
-
│ ├── config/
|
|
182
|
-
│ ├── controllers/
|
|
183
|
-
│ ├── models/
|
|
184
|
-
│ ├── routes/
|
|
185
|
-
│ ├── views/ # EJS or Pug templates
|
|
186
|
-
│ └── index.js|ts
|
|
187
|
-
└── ...
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Case C: Clean Architecture (REST API)
|
|
191
|
-
Separation of concerns with Domain, Use Cases, and Infrastructure.
|
|
192
|
-
|
|
193
|
-
```text
|
|
194
|
-
project-name/
|
|
195
|
-
├── src/
|
|
196
|
-
│ ├── domain/ # Entities (Enterprise rules)
|
|
197
|
-
│ ├── errors/ # ApiError, NotFoundError, BadRequestError
|
|
198
|
-
│ ├── use_cases/ # Application business rules
|
|
199
|
-
│ ├── interfaces/ # Adapters
|
|
200
|
-
│ │ ├── controllers/ # Use next(error) for error propagation
|
|
201
|
-
│ │ └── routes/ # Pass NextFunction through handlers
|
|
202
|
-
│ ├── infrastructure/ # Frameworks & Drivers
|
|
203
|
-
│ │ ├── config/ # Environment config
|
|
204
|
-
│ │ ├── caching/ # Redis Client
|
|
205
|
-
│ │ ├── database/ # DB connection & models
|
|
206
|
-
│ │ ├── repositories/ # Data access implementation
|
|
207
|
-
│ │ └── webserver/
|
|
208
|
-
│ │ ├── middlewares/
|
|
209
|
-
│ │ │ └── error.middleware.js # JS only — Express error handler
|
|
210
|
-
│ │ └── server.js # Express app setup
|
|
211
|
-
│ ├── utils/
|
|
212
|
-
│ │ └── error.middleware.ts # TS — global error handler
|
|
213
|
-
│ └── index.js|ts # Registers errorMiddleware after Apollo/Express
|
|
214
|
-
└── ...
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Case D: Clean Architecture (Kafka Worker)
|
|
218
|
-
Optimized for event-driven microservices. HTTP routes are removed.
|
|
219
|
-
|
|
220
|
-
```text
|
|
221
|
-
project-name/
|
|
222
|
-
├── src/
|
|
223
|
-
│ ├── domain/
|
|
224
|
-
│ ├── use_cases/
|
|
225
|
-
│ ├── infrastructure/
|
|
226
|
-
│ │ ├── config/ # Includes Kafka config
|
|
227
|
-
│ │ ├── database/
|
|
228
|
-
│ │ ├── messaging/ # Kafka Client/Consumer
|
|
229
|
-
│ │ ├── repositories/
|
|
230
|
-
│ │ └── webserver/ # (Optional/Minimal)
|
|
231
|
-
│ └── index.js|ts
|
|
232
|
-
└── ...
|
|
233
|
-
```
|
package/docs/releaseNoteRule.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Release Process
|
|
2
|
-
|
|
3
|
-
This document outlines the steps to release a new version of `nodejs-quickstart-structure`.
|
|
4
|
-
|
|
5
|
-
## 1. Update Changelog
|
|
6
|
-
|
|
7
|
-
Before releasing, update `CHANGELOG.md`:
|
|
8
|
-
1. Create a new header for the new version (e.g., `## [1.4.6] - 2026-02-12`).
|
|
9
|
-
2. Document new features, bug fixes, and changes.
|
|
10
|
-
3. Save the file.
|
|
11
|
-
|
|
12
|
-
## 2. Commit Changelog
|
|
13
|
-
|
|
14
|
-
Stage the `CHANGELOG.md` changes but **do not commit yet** if you want to include it in the version bump commit.
|
|
15
|
-
```bash
|
|
16
|
-
git add CHANGELOG.md
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## 3. Bump Version & Tag
|
|
20
|
-
|
|
21
|
-
Run the appropriate `npm version` command. This will assume you have a clean working directory (after staging `CHANGELOG.md`).
|
|
22
|
-
```bash
|
|
23
|
-
npm version patch # For bug fixes (1.4.5 -> 1.4.6)
|
|
24
|
-
npm version minor # For new features (1.4.5 -> 1.5.0)
|
|
25
|
-
npm version major # For breaking changes (1.4.5 -> 2.0.0)
|
|
26
|
-
```
|
|
27
|
-
*Note: This command automatically updates `package.json`, creates a git commit with the new version number, and creates a git tag (e.g., `v1.4.6`).*
|
|
28
|
-
|
|
29
|
-
## 4. Push Changes & Tags
|
|
30
|
-
|
|
31
|
-
Push the new commit and the new tag to GitHub:
|
|
32
|
-
```bash
|
|
33
|
-
git push origin main
|
|
34
|
-
git push origin --follow-tags
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## 5. Publish to NPM (Optional)
|
|
38
|
-
|
|
39
|
-
If you are publishing this package to the npm registry:
|
|
40
|
-
```bash
|
|
41
|
-
npm publish
|
|
42
|
-
```
|
package/docs/ruleDevelop.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Development Rules & Conventions
|
|
2
|
-
|
|
3
|
-
## General Standards
|
|
4
|
-
|
|
5
|
-
### File Naming
|
|
6
|
-
- **Controllers**: Use camelCase (e.g., `kafkaController.ts`, `userController.ts`).
|
|
7
|
-
- **Services**: Use camelCase (e.g., `kafkaService.ts`, `userService.ts`) or PascalCase depending on export type. Class-based services should generally match class name.
|
|
8
|
-
- **Routes**: Use camelCase (e.g., `userRoutes.ts`, `kafkaRoutes.ts`).
|
|
9
|
-
- **Utilities**: Use camelCase (e.g., `httpCodes.ts`).
|
|
10
|
-
|
|
11
|
-
### Code Style
|
|
12
|
-
- **Status Codes**: ALWAYS use `HTTP_STATUS` constants from `@/utils/httpCodes` (TS) or `../../utils/httpCodes.js` (JS) instead of hardcoded numbers.
|
|
13
|
-
- Good: `res.status(HTTP_STATUS.OK).json(...)`
|
|
14
|
-
- Bad: `res.status(200).json(...)`
|
|
15
|
-
- **Imports**:
|
|
16
|
-
- **TypeScript**: Use path aliases (e.g., `@/services/...`, `@/utils/...`) instead of relative paths (e.g., `../../utils/...`).
|
|
17
|
-
- **JavaScript**: Use relative paths as configured by the project structure.
|
|
18
|
-
|
|
19
|
-
### API Response Structure
|
|
20
|
-
- Success: `{ status: string, data: any }` or direct JSON object.
|
|
21
|
-
- Error: `{ error: string }`
|
|
22
|
-
|
|
23
|
-
## Git Workflow
|
|
24
|
-
- Commit messages should be descriptive.
|
|
25
|
-
- Ensure all tests pass before pushing.
|
|
26
|
-
|
|
27
|
-
## Verify function before commit
|
|
28
|
-
- npm run test:e2e
|
|
29
|
-
|
|
30
|
-
## Verify case sensitivity before commit
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<% if (language === 'TypeScript') { %>import request from 'supertest';
|
|
2
|
-
import express from 'express';<% } else { %>const request = require('supertest');
|
|
3
|
-
const express = require('express');<% } %>
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
app.get('/health', (req, res) => res.json({ status: 'UP' }));
|
|
7
|
-
|
|
8
|
-
describe('Health Check', () => {
|
|
9
|
-
it('should return 200 OK', async () => {
|
|
10
|
-
const res = await request(app).get('/health');
|
|
11
|
-
expect(res.status).toBe(200);
|
|
12
|
-
expect(res.body).toEqual({ status: 'UP' });
|
|
13
|
-
});
|
|
14
|
-
});
|
|
File without changes
|
|
File without changes
|