nestcraftx 0.2.4 → 0.2.6
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/.gitattributes +6 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- package/.github/ISSUE_TEMPLATE/pull_request_template.md +24 -0
- package/CHANGELOG.fr.md +97 -97
- package/CHANGELOG.md +98 -98
- package/CLI_USAGE.fr.md +331 -331
- package/CLI_USAGE.md +364 -364
- package/DEMO.fr.md +292 -292
- package/DEMO.md +294 -294
- package/LICENSE +21 -21
- package/MIGRATION_GUIDE.fr.md +127 -127
- package/MIGRATION_GUIDE.md +124 -124
- package/QUICK_START.fr.md +152 -152
- package/QUICK_START.md +169 -169
- package/README.fr.md +653 -659
- package/SECURITY.md +10 -0
- package/bin/nestcraft.js +84 -64
- package/commands/demo.js +333 -330
- package/commands/generate.js +93 -0
- package/commands/generateConf.js +91 -0
- package/commands/help.js +78 -78
- package/commands/info.js +48 -48
- package/commands/new.js +338 -335
- package/commands/start.js +19 -19
- package/commands/test.js +7 -7
- package/package.json +41 -41
- package/readme.md +638 -643
- package/utils/cliParser.js +133 -76
- package/utils/colors.js +62 -62
- package/utils/configs/configureDocker.js +120 -120
- package/utils/configs/setupCleanArchitecture.js +563 -557
- package/utils/configs/setupLightArchitecture.js +701 -660
- package/utils/envGenerator.js +122 -122
- package/utils/file-utils/packageJsonUtils.js +49 -55
- package/utils/file-utils/saveProjectConfig.js +36 -0
- package/utils/fullModeInput.js +607 -607
- package/utils/generators/application/dtoUpdater.js +54 -0
- package/utils/generators/cleanModuleGenerator.js +475 -0
- package/utils/generators/database/setupDatabase.js +31 -0
- package/utils/generators/domain/entityUpdater.js +78 -0
- package/utils/generators/infrastructure/mapperUpdater.js +65 -0
- package/utils/generators/lightModuleGenerator.js +131 -0
- package/utils/generators/relation/relation.engine.js +64 -0
- package/utils/interactive/askEntityInputs.js +165 -0
- package/utils/lightModeInput.js +460 -460
- package/utils/loggers/logError.js +7 -7
- package/utils/loggers/logInfo.js +7 -7
- package/utils/loggers/logSuccess.js +7 -7
- package/utils/loggers/logWarning.js +7 -7
- package/utils/setups/orms/typeOrmSetup.js +630 -630
- package/utils/setups/projectSetup.js +46 -46
- package/utils/setups/setupAuth.js +973 -926
- package/utils/setups/setupDatabase.js +75 -75
- package/utils/setups/setupLogger.js +69 -59
- package/utils/setups/setupMongoose.js +377 -432
- package/utils/setups/setupPrisma.js +802 -630
- package/utils/setups/setupSwagger.js +97 -88
- package/utils/shell.js +32 -32
- package/utils/spinner.js +57 -57
- package/utils/systemCheck.js +124 -124
- package/utils/userInput.js +421 -421
- package/utils/utils.js +2197 -1762
package/DEMO.fr.md
CHANGED
|
@@ -1,292 +1,292 @@
|
|
|
1
|
-
# NestCraftX CLI - Démo du projet `blog-demo` (v0.2.
|
|
2
|
-
|
|
3
|
-
## Objectif
|
|
4
|
-
|
|
5
|
-
Cette démo montre comment générer un projet NestJS complet avec **Clean Architecture**, prêt à exécuter, incluant :
|
|
6
|
-
|
|
7
|
-
- Auth JWT
|
|
8
|
-
- Swagger UI
|
|
9
|
-
- Docker (optionnel)
|
|
10
|
-
- ORM (Prisma, TypeORM ou Mongoose)
|
|
11
|
-
- Seeds pour remplir la base de données avec des données d'exemple
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 1️⃣ Lancer la démo
|
|
16
|
-
|
|
17
|
-
Tu as deux façons de générer le projet de démo blog-demo :
|
|
18
|
-
|
|
19
|
-
### Mode 1 : Interactif (Recommandé pour les premiers essais)
|
|
20
|
-
|
|
21
|
-
Le CLI te posera les questions pour chaque option manquante (ORM, Docker, etc.).
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npx nestcraftx demo
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Mode 2 : Silencieux (Configuration par flags)
|
|
28
|
-
|
|
29
|
-
Tu peux tout définir en ligne de commande. Le CLI ne posera aucune question. (Exemple complet)
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npx nestcraftx demo --light --auth --swagger --docker --orm prisma --packageManager npm
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Détail des Options :
|
|
36
|
-
|
|
37
|
-
- --light → Mode MVP simplifié (--full par défaut si omis).
|
|
38
|
-
|
|
39
|
-
- --auth → Auth JWT intégrée (true par défaut si omis).
|
|
40
|
-
|
|
41
|
-
- --swagger → Swagger UI activé (true par défaut si omis).
|
|
42
|
-
|
|
43
|
-
- --docker → Génère les fichiers Docker (true par défaut si omis).
|
|
44
|
-
|
|
45
|
-
- --orm → Choisir l'ORM et la base de données (`prisma`)
|
|
46
|
-
|
|
47
|
-
## 2️⃣ Structure du projet
|
|
48
|
-
|
|
49
|
-
Après génération, ton projet aura :
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
src
|
|
53
|
-
├── auth
|
|
54
|
-
│ ├── application
|
|
55
|
-
│ │ ├── dtos
|
|
56
|
-
│ │ │ ├── create-session.dto.ts
|
|
57
|
-
│ │ │ ├── forgotPassword.dto.ts
|
|
58
|
-
│ │ │ ├── loginCredential.dto.ts
|
|
59
|
-
│ │ │ ├── refreshToken.dto.ts
|
|
60
|
-
│ │ │ ├── resetPassword.dto.ts
|
|
61
|
-
│ │ │ ├── sendOtp.dto.ts
|
|
62
|
-
│ │ │ └── verifyOtp.dto.ts
|
|
63
|
-
│ │ └── services
|
|
64
|
-
│ │ ├── auth.service.ts
|
|
65
|
-
│ │ └── session.service.ts
|
|
66
|
-
│ ├── domain
|
|
67
|
-
│ │ ├── entities
|
|
68
|
-
│ │ │ └── session.entity.ts
|
|
69
|
-
│ │ └── interfaces
|
|
70
|
-
│ │ └── session.repository.interface.ts
|
|
71
|
-
│ ├── infrastructure
|
|
72
|
-
│ │ ├── guards
|
|
73
|
-
│ │ │ ├── jwt-auth.guard.ts
|
|
74
|
-
│ │ │ └── role.guard.ts
|
|
75
|
-
│ │ ├── mappers
|
|
76
|
-
│ │ │ └── session.mapper.ts
|
|
77
|
-
│ │ ├── persistence
|
|
78
|
-
│ │ │ └── session.repository.ts
|
|
79
|
-
│ │ └── strategies
|
|
80
|
-
│ │ └── jwt.strategy.ts
|
|
81
|
-
│ ├── presentation
|
|
82
|
-
│ │ └── controllers
|
|
83
|
-
│ │ └── auth.controller.ts
|
|
84
|
-
│ └── auth.module.ts
|
|
85
|
-
│
|
|
86
|
-
├── comment
|
|
87
|
-
│ ├── application
|
|
88
|
-
│ │ ├── dtos
|
|
89
|
-
│ │ │ └── comment.dto.ts
|
|
90
|
-
│ │ ├── services
|
|
91
|
-
│ │ │ └── comment.service.ts
|
|
92
|
-
│ │ └── use-cases
|
|
93
|
-
│ │ ├── create-comment.use-case.ts
|
|
94
|
-
│ │ ├── delete-comment.use-case.ts
|
|
95
|
-
│ │ ├── getAll-comment.use-case.ts
|
|
96
|
-
│ │ ├── getById-comment.use-case.ts
|
|
97
|
-
│ │ └── update-comment.use-case.ts
|
|
98
|
-
│ ├── domain
|
|
99
|
-
│ │ ├── entities
|
|
100
|
-
│ │ │ └── comment.entity.ts
|
|
101
|
-
│ │ ├── enums
|
|
102
|
-
│ │ └── interfaces
|
|
103
|
-
│ │ └── comment.repository.interface.ts
|
|
104
|
-
│ ├── infrastructure
|
|
105
|
-
│ │ ├── adapters
|
|
106
|
-
│ │ │ └── comment.adapter.ts
|
|
107
|
-
│ │ ├── mappers
|
|
108
|
-
│ │ │ └── comment.mapper.ts
|
|
109
|
-
│ │ └── repositories
|
|
110
|
-
│ │ └── comment.repository.ts
|
|
111
|
-
│ ├── presentation
|
|
112
|
-
│ │ └── controllers
|
|
113
|
-
│ │ └── comment.controller.ts
|
|
114
|
-
│ └── comment.module.ts
|
|
115
|
-
│
|
|
116
|
-
├── common
|
|
117
|
-
│ ├── decorators
|
|
118
|
-
│ │ ├── current-user.decorator.ts
|
|
119
|
-
│ │ ├── public.decorator.ts
|
|
120
|
-
│ │ └── role.decorator.ts
|
|
121
|
-
│ ├── filters
|
|
122
|
-
│ │ └── all-exceptions.filter.ts
|
|
123
|
-
│ ├── interceptors
|
|
124
|
-
│ │ └── response.interceptor.ts
|
|
125
|
-
│ └── middlewares
|
|
126
|
-
│ └── logger.middleware.ts
|
|
127
|
-
│
|
|
128
|
-
├── post
|
|
129
|
-
│ ├── application
|
|
130
|
-
│ │ ├── dtos
|
|
131
|
-
│ │ │ └── post.dto.ts
|
|
132
|
-
│ │ ├── services
|
|
133
|
-
│ │ │ └── post.service.ts
|
|
134
|
-
│ │ └── use-cases
|
|
135
|
-
│ │ ├── create-post.use-case.ts
|
|
136
|
-
│ │ ├── delete-post.use-case.ts
|
|
137
|
-
│ │ ├── getAll-post.use-case.ts
|
|
138
|
-
│ │ ├── getById-post.use-case.ts
|
|
139
|
-
│ │ └── update-post.use-case.ts
|
|
140
|
-
│ ├── domain
|
|
141
|
-
│ │ ├── entities
|
|
142
|
-
│ │ │ └── post.entity.ts
|
|
143
|
-
│ │ ├── enums
|
|
144
|
-
│ │ └── interfaces
|
|
145
|
-
│ │ └── post.repository.interface.ts
|
|
146
|
-
│ ├── infrastructure
|
|
147
|
-
│ │ ├── adapters
|
|
148
|
-
│ │ │ └── post.adapter.ts
|
|
149
|
-
│ │ ├── mappers
|
|
150
|
-
│ │ │ └── post.mapper.ts
|
|
151
|
-
│ │ └── repositories
|
|
152
|
-
│ │ └── post.repository.ts
|
|
153
|
-
│ ├── presentation
|
|
154
|
-
│ │ └── controllers
|
|
155
|
-
│ │ └── post.controller.ts
|
|
156
|
-
│ └── post.module.ts
|
|
157
|
-
│
|
|
158
|
-
├── user
|
|
159
|
-
│ ├── application
|
|
160
|
-
│ │ ├── dtos
|
|
161
|
-
│ │ │ └── user.dto.ts
|
|
162
|
-
│ │ ├── services
|
|
163
|
-
│ │ │ └── user.service.ts
|
|
164
|
-
│ │ └── use-cases
|
|
165
|
-
│ │ ├── create-user.use-case.ts
|
|
166
|
-
│ │ ├── delete-user.use-case.ts
|
|
167
|
-
│ │ ├── getAll-user.use-case.ts
|
|
168
|
-
│ │ ├── getById-user.use-case.ts
|
|
169
|
-
│ │ └── update-user.use-case.ts
|
|
170
|
-
│ ├── domain
|
|
171
|
-
│ │ ├── entities
|
|
172
|
-
│ │ │ └── user.entity.ts
|
|
173
|
-
│ │ ├── enums
|
|
174
|
-
│ │ │ └── role.enum.ts
|
|
175
|
-
│ │ └── interfaces
|
|
176
|
-
│ │ └── user.repository.interface.ts
|
|
177
|
-
│ ├── infrastructure
|
|
178
|
-
│ │ ├── adapters
|
|
179
|
-
│ │ │ └── user.adapter.ts
|
|
180
|
-
│ │ ├── mappers
|
|
181
|
-
│ │ │ └── user.mapper.ts
|
|
182
|
-
│ │ └── repositories
|
|
183
|
-
│ │ └── user.repository.ts
|
|
184
|
-
│ ├── presentation
|
|
185
|
-
│ │ └── controllers
|
|
186
|
-
│ │ └── user.controller.ts
|
|
187
|
-
│ └── user.module.ts
|
|
188
|
-
│
|
|
189
|
-
├── app.controller.spec.ts
|
|
190
|
-
├── app.controller.ts
|
|
191
|
-
├── app.module.ts
|
|
192
|
-
├── app.service.ts
|
|
193
|
-
└── main.ts
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
- Trois entités principales : `User`, `Post`, `Comment`
|
|
198
|
-
- Relations :
|
|
199
|
-
- User → Post (1:N )
|
|
200
|
-
- Post → Comment (1:N )
|
|
201
|
-
- User → Comment (1:N )
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## 3️⃣ Configuration de la base de données
|
|
206
|
-
|
|
207
|
-
### PostgreSQL (Prisma ou TypeORM)
|
|
208
|
-
|
|
209
|
-
1. Crée une base vide `blog_demo` :
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
createdb blog_demo
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
2. Mets à jour le fichier `.env` :
|
|
216
|
-
|
|
217
|
-
```env
|
|
218
|
-
POSTGRES_USER=<votre_user>
|
|
219
|
-
POSTGRES_PASSWORD=<votre_mot_de_passe>
|
|
220
|
-
POSTGRES_DB=blog_demo
|
|
221
|
-
POSTGRES_HOST=localhost
|
|
222
|
-
POSTGRES_PORT=5432
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
3. Exécute les migrations et seeds :
|
|
226
|
-
|
|
227
|
-
- Prisma :
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
npx prisma migrate reset
|
|
231
|
-
npx prisma migrate dev --name init
|
|
232
|
-
npx prisma db seed | npm run seed
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
- TypeORM :
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
npm run typeorm:migration:run
|
|
239
|
-
|
|
240
|
-
npm run typeorm:seed | npm run seed
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### MongoDB (Mongoose)
|
|
244
|
-
|
|
245
|
-
1. Vérifie que MongoDB est lancé (local ou Docker).
|
|
246
|
-
2. Mets à jour `.env` si nécessaire :
|
|
247
|
-
|
|
248
|
-
```env
|
|
249
|
-
MONGO_URI=mongodb://<user>:<password>@localhost:27017/blog_demo
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
3. Lance le script seed (si présent) :
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
npm run seed
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## 4️⃣ Lancer le projet
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
cd blog-demo
|
|
264
|
-
npm install
|
|
265
|
-
npm run start:dev
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
- Swagger UI disponible (si activé) : [http://localhost:3000/api/docs](http://localhost:3000/api/docs)
|
|
269
|
-
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## 5️⃣ Endpoints principaux
|
|
273
|
-
|
|
274
|
-
- **Auth** (si activé) :
|
|
275
|
-
- POST `/auth/register` → Créer un compte
|
|
276
|
-
- POST `/auth/login` → Se connecter
|
|
277
|
-
- **Users** : `/users`
|
|
278
|
-
- **Posts** : `/posts`
|
|
279
|
-
- **Comments** : `/comments`
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
## 6️⃣ Astuces
|
|
284
|
-
|
|
285
|
-
- Modifie le fichier `.env` pour connecter ta propre base.
|
|
286
|
-
- Exécute le seed pour remplir la base avec des données d’exemple.
|
|
287
|
-
- Le projet est prêt à être lancé immédiatement après configuration.
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
**NestCraftX v0.2.
|
|
292
|
-
[Documentation complète](https://github.com/august-dev-pro/NestCraftX)
|
|
1
|
+
# NestCraftX CLI - Démo du projet `blog-demo` (v0.2.5)
|
|
2
|
+
|
|
3
|
+
## Objectif
|
|
4
|
+
|
|
5
|
+
Cette démo montre comment générer un projet NestJS complet avec **Clean Architecture**, prêt à exécuter, incluant :
|
|
6
|
+
|
|
7
|
+
- Auth JWT
|
|
8
|
+
- Swagger UI
|
|
9
|
+
- Docker (optionnel)
|
|
10
|
+
- ORM (Prisma, TypeORM ou Mongoose)
|
|
11
|
+
- Seeds pour remplir la base de données avec des données d'exemple
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1️⃣ Lancer la démo
|
|
16
|
+
|
|
17
|
+
Tu as deux façons de générer le projet de démo blog-demo :
|
|
18
|
+
|
|
19
|
+
### Mode 1 : Interactif (Recommandé pour les premiers essais)
|
|
20
|
+
|
|
21
|
+
Le CLI te posera les questions pour chaque option manquante (ORM, Docker, etc.).
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx nestcraftx demo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Mode 2 : Silencieux (Configuration par flags)
|
|
28
|
+
|
|
29
|
+
Tu peux tout définir en ligne de commande. Le CLI ne posera aucune question. (Exemple complet)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx nestcraftx demo --light --auth --swagger --docker --orm prisma --packageManager npm
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Détail des Options :
|
|
36
|
+
|
|
37
|
+
- --light → Mode MVP simplifié (--full par défaut si omis).
|
|
38
|
+
|
|
39
|
+
- --auth → Auth JWT intégrée (true par défaut si omis).
|
|
40
|
+
|
|
41
|
+
- --swagger → Swagger UI activé (true par défaut si omis).
|
|
42
|
+
|
|
43
|
+
- --docker → Génère les fichiers Docker (true par défaut si omis).
|
|
44
|
+
|
|
45
|
+
- --orm → Choisir l'ORM et la base de données (`prisma`)
|
|
46
|
+
|
|
47
|
+
## 2️⃣ Structure du projet
|
|
48
|
+
|
|
49
|
+
Après génération, ton projet aura :
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
src
|
|
53
|
+
├── auth
|
|
54
|
+
│ ├── application
|
|
55
|
+
│ │ ├── dtos
|
|
56
|
+
│ │ │ ├── create-session.dto.ts
|
|
57
|
+
│ │ │ ├── forgotPassword.dto.ts
|
|
58
|
+
│ │ │ ├── loginCredential.dto.ts
|
|
59
|
+
│ │ │ ├── refreshToken.dto.ts
|
|
60
|
+
│ │ │ ├── resetPassword.dto.ts
|
|
61
|
+
│ │ │ ├── sendOtp.dto.ts
|
|
62
|
+
│ │ │ └── verifyOtp.dto.ts
|
|
63
|
+
│ │ └── services
|
|
64
|
+
│ │ ├── auth.service.ts
|
|
65
|
+
│ │ └── session.service.ts
|
|
66
|
+
│ ├── domain
|
|
67
|
+
│ │ ├── entities
|
|
68
|
+
│ │ │ └── session.entity.ts
|
|
69
|
+
│ │ └── interfaces
|
|
70
|
+
│ │ └── session.repository.interface.ts
|
|
71
|
+
│ ├── infrastructure
|
|
72
|
+
│ │ ├── guards
|
|
73
|
+
│ │ │ ├── jwt-auth.guard.ts
|
|
74
|
+
│ │ │ └── role.guard.ts
|
|
75
|
+
│ │ ├── mappers
|
|
76
|
+
│ │ │ └── session.mapper.ts
|
|
77
|
+
│ │ ├── persistence
|
|
78
|
+
│ │ │ └── session.repository.ts
|
|
79
|
+
│ │ └── strategies
|
|
80
|
+
│ │ └── jwt.strategy.ts
|
|
81
|
+
│ ├── presentation
|
|
82
|
+
│ │ └── controllers
|
|
83
|
+
│ │ └── auth.controller.ts
|
|
84
|
+
│ └── auth.module.ts
|
|
85
|
+
│
|
|
86
|
+
├── comment
|
|
87
|
+
│ ├── application
|
|
88
|
+
│ │ ├── dtos
|
|
89
|
+
│ │ │ └── comment.dto.ts
|
|
90
|
+
│ │ ├── services
|
|
91
|
+
│ │ │ └── comment.service.ts
|
|
92
|
+
│ │ └── use-cases
|
|
93
|
+
│ │ ├── create-comment.use-case.ts
|
|
94
|
+
│ │ ├── delete-comment.use-case.ts
|
|
95
|
+
│ │ ├── getAll-comment.use-case.ts
|
|
96
|
+
│ │ ├── getById-comment.use-case.ts
|
|
97
|
+
│ │ └── update-comment.use-case.ts
|
|
98
|
+
│ ├── domain
|
|
99
|
+
│ │ ├── entities
|
|
100
|
+
│ │ │ └── comment.entity.ts
|
|
101
|
+
│ │ ├── enums
|
|
102
|
+
│ │ └── interfaces
|
|
103
|
+
│ │ └── comment.repository.interface.ts
|
|
104
|
+
│ ├── infrastructure
|
|
105
|
+
│ │ ├── adapters
|
|
106
|
+
│ │ │ └── comment.adapter.ts
|
|
107
|
+
│ │ ├── mappers
|
|
108
|
+
│ │ │ └── comment.mapper.ts
|
|
109
|
+
│ │ └── repositories
|
|
110
|
+
│ │ └── comment.repository.ts
|
|
111
|
+
│ ├── presentation
|
|
112
|
+
│ │ └── controllers
|
|
113
|
+
│ │ └── comment.controller.ts
|
|
114
|
+
│ └── comment.module.ts
|
|
115
|
+
│
|
|
116
|
+
├── common
|
|
117
|
+
│ ├── decorators
|
|
118
|
+
│ │ ├── current-user.decorator.ts
|
|
119
|
+
│ │ ├── public.decorator.ts
|
|
120
|
+
│ │ └── role.decorator.ts
|
|
121
|
+
│ ├── filters
|
|
122
|
+
│ │ └── all-exceptions.filter.ts
|
|
123
|
+
│ ├── interceptors
|
|
124
|
+
│ │ └── response.interceptor.ts
|
|
125
|
+
│ └── middlewares
|
|
126
|
+
│ └── logger.middleware.ts
|
|
127
|
+
│
|
|
128
|
+
├── post
|
|
129
|
+
│ ├── application
|
|
130
|
+
│ │ ├── dtos
|
|
131
|
+
│ │ │ └── post.dto.ts
|
|
132
|
+
│ │ ├── services
|
|
133
|
+
│ │ │ └── post.service.ts
|
|
134
|
+
│ │ └── use-cases
|
|
135
|
+
│ │ ├── create-post.use-case.ts
|
|
136
|
+
│ │ ├── delete-post.use-case.ts
|
|
137
|
+
│ │ ├── getAll-post.use-case.ts
|
|
138
|
+
│ │ ├── getById-post.use-case.ts
|
|
139
|
+
│ │ └── update-post.use-case.ts
|
|
140
|
+
│ ├── domain
|
|
141
|
+
│ │ ├── entities
|
|
142
|
+
│ │ │ └── post.entity.ts
|
|
143
|
+
│ │ ├── enums
|
|
144
|
+
│ │ └── interfaces
|
|
145
|
+
│ │ └── post.repository.interface.ts
|
|
146
|
+
│ ├── infrastructure
|
|
147
|
+
│ │ ├── adapters
|
|
148
|
+
│ │ │ └── post.adapter.ts
|
|
149
|
+
│ │ ├── mappers
|
|
150
|
+
│ │ │ └── post.mapper.ts
|
|
151
|
+
│ │ └── repositories
|
|
152
|
+
│ │ └── post.repository.ts
|
|
153
|
+
│ ├── presentation
|
|
154
|
+
│ │ └── controllers
|
|
155
|
+
│ │ └── post.controller.ts
|
|
156
|
+
│ └── post.module.ts
|
|
157
|
+
│
|
|
158
|
+
├── user
|
|
159
|
+
│ ├── application
|
|
160
|
+
│ │ ├── dtos
|
|
161
|
+
│ │ │ └── user.dto.ts
|
|
162
|
+
│ │ ├── services
|
|
163
|
+
│ │ │ └── user.service.ts
|
|
164
|
+
│ │ └── use-cases
|
|
165
|
+
│ │ ├── create-user.use-case.ts
|
|
166
|
+
│ │ ├── delete-user.use-case.ts
|
|
167
|
+
│ │ ├── getAll-user.use-case.ts
|
|
168
|
+
│ │ ├── getById-user.use-case.ts
|
|
169
|
+
│ │ └── update-user.use-case.ts
|
|
170
|
+
│ ├── domain
|
|
171
|
+
│ │ ├── entities
|
|
172
|
+
│ │ │ └── user.entity.ts
|
|
173
|
+
│ │ ├── enums
|
|
174
|
+
│ │ │ └── role.enum.ts
|
|
175
|
+
│ │ └── interfaces
|
|
176
|
+
│ │ └── user.repository.interface.ts
|
|
177
|
+
│ ├── infrastructure
|
|
178
|
+
│ │ ├── adapters
|
|
179
|
+
│ │ │ └── user.adapter.ts
|
|
180
|
+
│ │ ├── mappers
|
|
181
|
+
│ │ │ └── user.mapper.ts
|
|
182
|
+
│ │ └── repositories
|
|
183
|
+
│ │ └── user.repository.ts
|
|
184
|
+
│ ├── presentation
|
|
185
|
+
│ │ └── controllers
|
|
186
|
+
│ │ └── user.controller.ts
|
|
187
|
+
│ └── user.module.ts
|
|
188
|
+
│
|
|
189
|
+
├── app.controller.spec.ts
|
|
190
|
+
├── app.controller.ts
|
|
191
|
+
├── app.module.ts
|
|
192
|
+
├── app.service.ts
|
|
193
|
+
└── main.ts
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
- Trois entités principales : `User`, `Post`, `Comment`
|
|
198
|
+
- Relations :
|
|
199
|
+
- User → Post (1:N )
|
|
200
|
+
- Post → Comment (1:N )
|
|
201
|
+
- User → Comment (1:N )
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 3️⃣ Configuration de la base de données
|
|
206
|
+
|
|
207
|
+
### PostgreSQL (Prisma ou TypeORM)
|
|
208
|
+
|
|
209
|
+
1. Crée une base vide `blog_demo` :
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
createdb blog_demo
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
2. Mets à jour le fichier `.env` :
|
|
216
|
+
|
|
217
|
+
```env
|
|
218
|
+
POSTGRES_USER=<votre_user>
|
|
219
|
+
POSTGRES_PASSWORD=<votre_mot_de_passe>
|
|
220
|
+
POSTGRES_DB=blog_demo
|
|
221
|
+
POSTGRES_HOST=localhost
|
|
222
|
+
POSTGRES_PORT=5432
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
3. Exécute les migrations et seeds :
|
|
226
|
+
|
|
227
|
+
- Prisma :
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npx prisma migrate reset
|
|
231
|
+
npx prisma migrate dev --name init
|
|
232
|
+
npx prisma db seed | npm run seed
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- TypeORM :
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npm run typeorm:migration:run
|
|
239
|
+
|
|
240
|
+
npm run typeorm:seed | npm run seed
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### MongoDB (Mongoose)
|
|
244
|
+
|
|
245
|
+
1. Vérifie que MongoDB est lancé (local ou Docker).
|
|
246
|
+
2. Mets à jour `.env` si nécessaire :
|
|
247
|
+
|
|
248
|
+
```env
|
|
249
|
+
MONGO_URI=mongodb://<user>:<password>@localhost:27017/blog_demo
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
3. Lance le script seed (si présent) :
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm run seed
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 4️⃣ Lancer le projet
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
cd blog-demo
|
|
264
|
+
npm install
|
|
265
|
+
npm run start:dev
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
- Swagger UI disponible (si activé) : [http://localhost:3000/api/docs](http://localhost:3000/api/docs)
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## 5️⃣ Endpoints principaux
|
|
273
|
+
|
|
274
|
+
- **Auth** (si activé) :
|
|
275
|
+
- POST `/auth/register` → Créer un compte
|
|
276
|
+
- POST `/auth/login` → Se connecter
|
|
277
|
+
- **Users** : `/users`
|
|
278
|
+
- **Posts** : `/posts`
|
|
279
|
+
- **Comments** : `/comments`
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 6️⃣ Astuces
|
|
284
|
+
|
|
285
|
+
- Modifie le fichier `.env` pour connecter ta propre base.
|
|
286
|
+
- Exécute le seed pour remplir la base avec des données d’exemple.
|
|
287
|
+
- Le projet est prêt à être lancé immédiatement après configuration.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
**NestCraftX v0.2.5** – Clean Architecture Generator for NestJS
|
|
292
|
+
[Documentation complète](https://github.com/august-dev-pro/NestCraftX)
|