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.md
CHANGED
|
@@ -1,294 +1,294 @@
|
|
|
1
|
-
# NestCraftX CLI - Demo Project `blog-demo` (v0.2.
|
|
2
|
-
|
|
3
|
-
## Objective
|
|
4
|
-
|
|
5
|
-
This demo shows how to generate a complete NestJS project with **Clean Architecture**, ready to run, including:
|
|
6
|
-
|
|
7
|
-
- JWT Auth
|
|
8
|
-
- Swagger UI
|
|
9
|
-
- Docker (optional)
|
|
10
|
-
- ORM (Prisma, TypeORM or Mongoose)
|
|
11
|
-
- Seeds to populate the database with sample data
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 1️⃣ Launch the Demo
|
|
16
|
-
|
|
17
|
-
You have two ways to generate the blog-demo demo project:
|
|
18
|
-
|
|
19
|
-
### Mode 1: Interactive (Recommended for first tries)
|
|
20
|
-
|
|
21
|
-
The CLI will ask you questions for each missing option (ORM, Docker, etc.).
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npx nestcraftx demo
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Mode 2: Silent (Configuration via flags)
|
|
28
|
-
|
|
29
|
-
You can define everything from the command line. The CLI will ask no questions. (Complete example)
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npx nestcraftx demo --light --auth --swagger --docker --orm prisma --packageManager npm
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Option Details:
|
|
36
|
-
|
|
37
|
-
- --light → Simplified MVP mode (--full by default if omitted).
|
|
38
|
-
|
|
39
|
-
- --auth → Integrated JWT Auth (true by default if omitted).
|
|
40
|
-
|
|
41
|
-
- --swagger → Swagger UI enabled (true by default if omitted).
|
|
42
|
-
|
|
43
|
-
- --docker → Generate Docker files (true by default if omitted).
|
|
44
|
-
|
|
45
|
-
- --orm → Choose the ORM and database (`prisma`, `typeorm`, or `mongoose`).
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## 2️⃣ Project Structure
|
|
50
|
-
|
|
51
|
-
After generation, your project will have:
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
src
|
|
55
|
-
├── auth
|
|
56
|
-
│ ├── application
|
|
57
|
-
│ │ ├── dtos
|
|
58
|
-
│ │ │ ├── create-session.dto.ts
|
|
59
|
-
│ │ │ ├── forgotPassword.dto.ts
|
|
60
|
-
│ │ │ ├── loginCredential.dto.ts
|
|
61
|
-
│ │ │ ├── refreshToken.dto.ts
|
|
62
|
-
│ │ │ ├── resetPassword.dto.ts
|
|
63
|
-
│ │ │ ├── sendOtp.dto.ts
|
|
64
|
-
│ │ │ └── verifyOtp.dto.ts
|
|
65
|
-
│ │ └── services
|
|
66
|
-
│ │ ├── auth.service.ts
|
|
67
|
-
│ │ └── session.service.ts
|
|
68
|
-
│ ├── domain
|
|
69
|
-
│ │ ├── entities
|
|
70
|
-
│ │ │ └── session.entity.ts
|
|
71
|
-
│ │ └── interfaces
|
|
72
|
-
│ │ └── session.repository.interface.ts
|
|
73
|
-
│ ├── infrastructure
|
|
74
|
-
│ │ ├── guards
|
|
75
|
-
│ │ │ ├── jwt-auth.guard.ts
|
|
76
|
-
│ │ │ └── role.guard.ts
|
|
77
|
-
│ │ ├── mappers
|
|
78
|
-
│ │ │ └── session.mapper.ts
|
|
79
|
-
│ │ ├── persistence
|
|
80
|
-
│ │ │ └── session.repository.ts
|
|
81
|
-
│ │ └── strategies
|
|
82
|
-
│ │ └── jwt.strategy.ts
|
|
83
|
-
│ ├── presentation
|
|
84
|
-
│ │ └── controllers
|
|
85
|
-
│ │ └── auth.controller.ts
|
|
86
|
-
│ └── auth.module.ts
|
|
87
|
-
│
|
|
88
|
-
├── comment
|
|
89
|
-
│ ├── application
|
|
90
|
-
│ │ ├── dtos
|
|
91
|
-
│ │ │ └── comment.dto.ts
|
|
92
|
-
│ │ ├── services
|
|
93
|
-
│ │ │ └── comment.service.ts
|
|
94
|
-
│ │ └── use-cases
|
|
95
|
-
│ │ ├── create-comment.use-case.ts
|
|
96
|
-
│ │ ├── delete-comment.use-case.ts
|
|
97
|
-
│ │ ├── getAll-comment.use-case.ts
|
|
98
|
-
│ │ ├── getById-comment.use-case.ts
|
|
99
|
-
│ │ └── update-comment.use-case.ts
|
|
100
|
-
│ ├── domain
|
|
101
|
-
│ │ ├── entities
|
|
102
|
-
│ │ │ └── comment.entity.ts
|
|
103
|
-
│ │ ├── enums
|
|
104
|
-
│ │ └── interfaces
|
|
105
|
-
│ │ └── comment.repository.interface.ts
|
|
106
|
-
│ ├── infrastructure
|
|
107
|
-
│ │ ├── adapters
|
|
108
|
-
│ │ │ └── comment.adapter.ts
|
|
109
|
-
│ │ ├── mappers
|
|
110
|
-
│ │ │ └── comment.mapper.ts
|
|
111
|
-
│ │ └── repositories
|
|
112
|
-
│ │ └── comment.repository.ts
|
|
113
|
-
│ ├── presentation
|
|
114
|
-
│ │ └── controllers
|
|
115
|
-
│ │ └── comment.controller.ts
|
|
116
|
-
│ └── comment.module.ts
|
|
117
|
-
│
|
|
118
|
-
├── common
|
|
119
|
-
│ ├── decorators
|
|
120
|
-
│ │ ├── current-user.decorator.ts
|
|
121
|
-
│ │ ├── public.decorator.ts
|
|
122
|
-
│ │ └── role.decorator.ts
|
|
123
|
-
│ ├── filters
|
|
124
|
-
│ │ └── all-exceptions.filter.ts
|
|
125
|
-
│ ├── interceptors
|
|
126
|
-
│ │ └── response.interceptor.ts
|
|
127
|
-
│ └── middlewares
|
|
128
|
-
│ └── logger.middleware.ts
|
|
129
|
-
│
|
|
130
|
-
├── post
|
|
131
|
-
│ ├── application
|
|
132
|
-
│ │ ├── dtos
|
|
133
|
-
│ │ │ └── post.dto.ts
|
|
134
|
-
│ │ ├── services
|
|
135
|
-
│ │ │ └── post.service.ts
|
|
136
|
-
│ │ └── use-cases
|
|
137
|
-
│ │ ├── create-post.use-case.ts
|
|
138
|
-
│ │ ├── delete-post.use-case.ts
|
|
139
|
-
│ │ ├── getAll-post.use-case.ts
|
|
140
|
-
│ │ ├── getById-post.use-case.ts
|
|
141
|
-
│ │ └── update-post.use-case.ts
|
|
142
|
-
│ ├── domain
|
|
143
|
-
│ │ ├── entities
|
|
144
|
-
│ │ │ └── post.entity.ts
|
|
145
|
-
│ │ ├── enums
|
|
146
|
-
│ │ └── interfaces
|
|
147
|
-
│ │ └── post.repository.interface.ts
|
|
148
|
-
│ ├── infrastructure
|
|
149
|
-
│ │ ├── adapters
|
|
150
|
-
│ │ │ └── post.adapter.ts
|
|
151
|
-
│ │ ├── mappers
|
|
152
|
-
│ │ │ └── post.mapper.ts
|
|
153
|
-
│ │ └── repositories
|
|
154
|
-
│ │ └── post.repository.ts
|
|
155
|
-
│ ├── presentation
|
|
156
|
-
│ │ └── controllers
|
|
157
|
-
│ │ └── post.controller.ts
|
|
158
|
-
│ └── post.module.ts
|
|
159
|
-
│
|
|
160
|
-
├── user
|
|
161
|
-
│ ├── application
|
|
162
|
-
│ │ ├── dtos
|
|
163
|
-
│ │ │ └── user.dto.ts
|
|
164
|
-
│ │ ├── services
|
|
165
|
-
│ │ │ └── user.service.ts
|
|
166
|
-
│ │ └── use-cases
|
|
167
|
-
│ │ ├── create-user.use-case.ts
|
|
168
|
-
│ │ ├── delete-user.use-case.ts
|
|
169
|
-
│ │ ├── getAll-user.use-case.ts
|
|
170
|
-
│ │ ├── getById-user.use-case.ts
|
|
171
|
-
│ │ └── update-user.use-case.ts
|
|
172
|
-
│ ├── domain
|
|
173
|
-
│ │ ├── entities
|
|
174
|
-
│ │ │ └── user.entity.ts
|
|
175
|
-
│ │ ├── enums
|
|
176
|
-
│ │ │ └── role.enum.ts
|
|
177
|
-
│ │ └── interfaces
|
|
178
|
-
│ │ └── user.repository.interface.ts
|
|
179
|
-
│ ├── infrastructure
|
|
180
|
-
│ │ ├── adapters
|
|
181
|
-
│ │ │ └── user.adapter.ts
|
|
182
|
-
│ │ ├── mappers
|
|
183
|
-
│ │ │ └── user.mapper.ts
|
|
184
|
-
│ │ └── repositories
|
|
185
|
-
│ │ └── user.repository.ts
|
|
186
|
-
│ ├── presentation
|
|
187
|
-
│ │ └── controllers
|
|
188
|
-
│ │ └── user.controller.ts
|
|
189
|
-
│ └── user.module.ts
|
|
190
|
-
│
|
|
191
|
-
├── app.controller.spec.ts
|
|
192
|
-
├── app.controller.ts
|
|
193
|
-
├── app.module.ts
|
|
194
|
-
├── app.service.ts
|
|
195
|
-
└── main.ts
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
- Three main entities: `User`, `Post`, `Comment`
|
|
200
|
-
- Relationships:
|
|
201
|
-
- User → Post (1:N )
|
|
202
|
-
- Post → Comment (1:N )
|
|
203
|
-
- User → Comment (1:N )
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## 3️⃣ Database Configuration
|
|
208
|
-
|
|
209
|
-
### PostgreSQL (Prisma or TypeORM)
|
|
210
|
-
|
|
211
|
-
1. Create an empty database `blog_demo`:
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
createdb blog_demo
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
2. Update the `.env` file:
|
|
218
|
-
|
|
219
|
-
```env
|
|
220
|
-
POSTGRES_USER=<your_user>
|
|
221
|
-
POSTGRES_PASSWORD=<your_password>
|
|
222
|
-
POSTGRES_DB=blog_demo
|
|
223
|
-
POSTGRES_HOST=localhost
|
|
224
|
-
POSTGRES_PORT=5432
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
3. Run migrations and seeds:
|
|
228
|
-
|
|
229
|
-
- Prisma:
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
npx prisma migrate reset
|
|
233
|
-
npx prisma migrate dev --name init
|
|
234
|
-
npx prisma db seed | npm run seed
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
- TypeORM:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
npm run typeorm:migration:run
|
|
241
|
-
|
|
242
|
-
npm run typeorm:seed | npm run seed
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### MongoDB (Mongoose)
|
|
246
|
-
|
|
247
|
-
1. Make sure MongoDB is running (local or Docker).
|
|
248
|
-
2. Update `.env` if necessary:
|
|
249
|
-
|
|
250
|
-
```env
|
|
251
|
-
MONGO_URI=mongodb://<user>:<password>@localhost:27017/blog_demo
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
3. Run the seed script (if present):
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
npm run seed
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
---
|
|
261
|
-
|
|
262
|
-
## 4️⃣ Run the Project
|
|
263
|
-
|
|
264
|
-
```bash
|
|
265
|
-
cd blog-demo
|
|
266
|
-
npm install
|
|
267
|
-
npm run start:dev
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
- Swagger UI available (if enabled): [http://localhost:3000/api/docs](http://localhost:3000/api/docs)
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## 5️⃣ Main Endpoints
|
|
275
|
-
|
|
276
|
-
- **Auth** (if enabled):
|
|
277
|
-
- POST `/auth/register` → Create an account
|
|
278
|
-
- POST `/auth/login` → Log in
|
|
279
|
-
- **Users**: `/users`
|
|
280
|
-
- **Posts**: `/posts`
|
|
281
|
-
- **Comments**: `/comments`
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
## 6️⃣ Tips
|
|
286
|
-
|
|
287
|
-
- Edit the `.env` file to connect to your own database.
|
|
288
|
-
- Run the seed to populate the database with sample data.
|
|
289
|
-
- The project is ready to launch immediately after configuration.
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
**NestCraftX v0.2.
|
|
294
|
-
[Complete Documentation](https://github.com/august-dev-pro/NestCraftX)
|
|
1
|
+
# NestCraftX CLI - Demo Project `blog-demo` (v0.2.5)
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
|
|
5
|
+
This demo shows how to generate a complete NestJS project with **Clean Architecture**, ready to run, including:
|
|
6
|
+
|
|
7
|
+
- JWT Auth
|
|
8
|
+
- Swagger UI
|
|
9
|
+
- Docker (optional)
|
|
10
|
+
- ORM (Prisma, TypeORM or Mongoose)
|
|
11
|
+
- Seeds to populate the database with sample data
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1️⃣ Launch the Demo
|
|
16
|
+
|
|
17
|
+
You have two ways to generate the blog-demo demo project:
|
|
18
|
+
|
|
19
|
+
### Mode 1: Interactive (Recommended for first tries)
|
|
20
|
+
|
|
21
|
+
The CLI will ask you questions for each missing option (ORM, Docker, etc.).
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx nestcraftx demo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Mode 2: Silent (Configuration via flags)
|
|
28
|
+
|
|
29
|
+
You can define everything from the command line. The CLI will ask no questions. (Complete example)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx nestcraftx demo --light --auth --swagger --docker --orm prisma --packageManager npm
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Option Details:
|
|
36
|
+
|
|
37
|
+
- --light → Simplified MVP mode (--full by default if omitted).
|
|
38
|
+
|
|
39
|
+
- --auth → Integrated JWT Auth (true by default if omitted).
|
|
40
|
+
|
|
41
|
+
- --swagger → Swagger UI enabled (true by default if omitted).
|
|
42
|
+
|
|
43
|
+
- --docker → Generate Docker files (true by default if omitted).
|
|
44
|
+
|
|
45
|
+
- --orm → Choose the ORM and database (`prisma`, `typeorm`, or `mongoose`).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 2️⃣ Project Structure
|
|
50
|
+
|
|
51
|
+
After generation, your project will have:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
src
|
|
55
|
+
├── auth
|
|
56
|
+
│ ├── application
|
|
57
|
+
│ │ ├── dtos
|
|
58
|
+
│ │ │ ├── create-session.dto.ts
|
|
59
|
+
│ │ │ ├── forgotPassword.dto.ts
|
|
60
|
+
│ │ │ ├── loginCredential.dto.ts
|
|
61
|
+
│ │ │ ├── refreshToken.dto.ts
|
|
62
|
+
│ │ │ ├── resetPassword.dto.ts
|
|
63
|
+
│ │ │ ├── sendOtp.dto.ts
|
|
64
|
+
│ │ │ └── verifyOtp.dto.ts
|
|
65
|
+
│ │ └── services
|
|
66
|
+
│ │ ├── auth.service.ts
|
|
67
|
+
│ │ └── session.service.ts
|
|
68
|
+
│ ├── domain
|
|
69
|
+
│ │ ├── entities
|
|
70
|
+
│ │ │ └── session.entity.ts
|
|
71
|
+
│ │ └── interfaces
|
|
72
|
+
│ │ └── session.repository.interface.ts
|
|
73
|
+
│ ├── infrastructure
|
|
74
|
+
│ │ ├── guards
|
|
75
|
+
│ │ │ ├── jwt-auth.guard.ts
|
|
76
|
+
│ │ │ └── role.guard.ts
|
|
77
|
+
│ │ ├── mappers
|
|
78
|
+
│ │ │ └── session.mapper.ts
|
|
79
|
+
│ │ ├── persistence
|
|
80
|
+
│ │ │ └── session.repository.ts
|
|
81
|
+
│ │ └── strategies
|
|
82
|
+
│ │ └── jwt.strategy.ts
|
|
83
|
+
│ ├── presentation
|
|
84
|
+
│ │ └── controllers
|
|
85
|
+
│ │ └── auth.controller.ts
|
|
86
|
+
│ └── auth.module.ts
|
|
87
|
+
│
|
|
88
|
+
├── comment
|
|
89
|
+
│ ├── application
|
|
90
|
+
│ │ ├── dtos
|
|
91
|
+
│ │ │ └── comment.dto.ts
|
|
92
|
+
│ │ ├── services
|
|
93
|
+
│ │ │ └── comment.service.ts
|
|
94
|
+
│ │ └── use-cases
|
|
95
|
+
│ │ ├── create-comment.use-case.ts
|
|
96
|
+
│ │ ├── delete-comment.use-case.ts
|
|
97
|
+
│ │ ├── getAll-comment.use-case.ts
|
|
98
|
+
│ │ ├── getById-comment.use-case.ts
|
|
99
|
+
│ │ └── update-comment.use-case.ts
|
|
100
|
+
│ ├── domain
|
|
101
|
+
│ │ ├── entities
|
|
102
|
+
│ │ │ └── comment.entity.ts
|
|
103
|
+
│ │ ├── enums
|
|
104
|
+
│ │ └── interfaces
|
|
105
|
+
│ │ └── comment.repository.interface.ts
|
|
106
|
+
│ ├── infrastructure
|
|
107
|
+
│ │ ├── adapters
|
|
108
|
+
│ │ │ └── comment.adapter.ts
|
|
109
|
+
│ │ ├── mappers
|
|
110
|
+
│ │ │ └── comment.mapper.ts
|
|
111
|
+
│ │ └── repositories
|
|
112
|
+
│ │ └── comment.repository.ts
|
|
113
|
+
│ ├── presentation
|
|
114
|
+
│ │ └── controllers
|
|
115
|
+
│ │ └── comment.controller.ts
|
|
116
|
+
│ └── comment.module.ts
|
|
117
|
+
│
|
|
118
|
+
├── common
|
|
119
|
+
│ ├── decorators
|
|
120
|
+
│ │ ├── current-user.decorator.ts
|
|
121
|
+
│ │ ├── public.decorator.ts
|
|
122
|
+
│ │ └── role.decorator.ts
|
|
123
|
+
│ ├── filters
|
|
124
|
+
│ │ └── all-exceptions.filter.ts
|
|
125
|
+
│ ├── interceptors
|
|
126
|
+
│ │ └── response.interceptor.ts
|
|
127
|
+
│ └── middlewares
|
|
128
|
+
│ └── logger.middleware.ts
|
|
129
|
+
│
|
|
130
|
+
├── post
|
|
131
|
+
│ ├── application
|
|
132
|
+
│ │ ├── dtos
|
|
133
|
+
│ │ │ └── post.dto.ts
|
|
134
|
+
│ │ ├── services
|
|
135
|
+
│ │ │ └── post.service.ts
|
|
136
|
+
│ │ └── use-cases
|
|
137
|
+
│ │ ├── create-post.use-case.ts
|
|
138
|
+
│ │ ├── delete-post.use-case.ts
|
|
139
|
+
│ │ ├── getAll-post.use-case.ts
|
|
140
|
+
│ │ ├── getById-post.use-case.ts
|
|
141
|
+
│ │ └── update-post.use-case.ts
|
|
142
|
+
│ ├── domain
|
|
143
|
+
│ │ ├── entities
|
|
144
|
+
│ │ │ └── post.entity.ts
|
|
145
|
+
│ │ ├── enums
|
|
146
|
+
│ │ └── interfaces
|
|
147
|
+
│ │ └── post.repository.interface.ts
|
|
148
|
+
│ ├── infrastructure
|
|
149
|
+
│ │ ├── adapters
|
|
150
|
+
│ │ │ └── post.adapter.ts
|
|
151
|
+
│ │ ├── mappers
|
|
152
|
+
│ │ │ └── post.mapper.ts
|
|
153
|
+
│ │ └── repositories
|
|
154
|
+
│ │ └── post.repository.ts
|
|
155
|
+
│ ├── presentation
|
|
156
|
+
│ │ └── controllers
|
|
157
|
+
│ │ └── post.controller.ts
|
|
158
|
+
│ └── post.module.ts
|
|
159
|
+
│
|
|
160
|
+
├── user
|
|
161
|
+
│ ├── application
|
|
162
|
+
│ │ ├── dtos
|
|
163
|
+
│ │ │ └── user.dto.ts
|
|
164
|
+
│ │ ├── services
|
|
165
|
+
│ │ │ └── user.service.ts
|
|
166
|
+
│ │ └── use-cases
|
|
167
|
+
│ │ ├── create-user.use-case.ts
|
|
168
|
+
│ │ ├── delete-user.use-case.ts
|
|
169
|
+
│ │ ├── getAll-user.use-case.ts
|
|
170
|
+
│ │ ├── getById-user.use-case.ts
|
|
171
|
+
│ │ └── update-user.use-case.ts
|
|
172
|
+
│ ├── domain
|
|
173
|
+
│ │ ├── entities
|
|
174
|
+
│ │ │ └── user.entity.ts
|
|
175
|
+
│ │ ├── enums
|
|
176
|
+
│ │ │ └── role.enum.ts
|
|
177
|
+
│ │ └── interfaces
|
|
178
|
+
│ │ └── user.repository.interface.ts
|
|
179
|
+
│ ├── infrastructure
|
|
180
|
+
│ │ ├── adapters
|
|
181
|
+
│ │ │ └── user.adapter.ts
|
|
182
|
+
│ │ ├── mappers
|
|
183
|
+
│ │ │ └── user.mapper.ts
|
|
184
|
+
│ │ └── repositories
|
|
185
|
+
│ │ └── user.repository.ts
|
|
186
|
+
│ ├── presentation
|
|
187
|
+
│ │ └── controllers
|
|
188
|
+
│ │ └── user.controller.ts
|
|
189
|
+
│ └── user.module.ts
|
|
190
|
+
│
|
|
191
|
+
├── app.controller.spec.ts
|
|
192
|
+
├── app.controller.ts
|
|
193
|
+
├── app.module.ts
|
|
194
|
+
├── app.service.ts
|
|
195
|
+
└── main.ts
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- Three main entities: `User`, `Post`, `Comment`
|
|
200
|
+
- Relationships:
|
|
201
|
+
- User → Post (1:N )
|
|
202
|
+
- Post → Comment (1:N )
|
|
203
|
+
- User → Comment (1:N )
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 3️⃣ Database Configuration
|
|
208
|
+
|
|
209
|
+
### PostgreSQL (Prisma or TypeORM)
|
|
210
|
+
|
|
211
|
+
1. Create an empty database `blog_demo`:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
createdb blog_demo
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
2. Update the `.env` file:
|
|
218
|
+
|
|
219
|
+
```env
|
|
220
|
+
POSTGRES_USER=<your_user>
|
|
221
|
+
POSTGRES_PASSWORD=<your_password>
|
|
222
|
+
POSTGRES_DB=blog_demo
|
|
223
|
+
POSTGRES_HOST=localhost
|
|
224
|
+
POSTGRES_PORT=5432
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
3. Run migrations and seeds:
|
|
228
|
+
|
|
229
|
+
- Prisma:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
npx prisma migrate reset
|
|
233
|
+
npx prisma migrate dev --name init
|
|
234
|
+
npx prisma db seed | npm run seed
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- TypeORM:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
npm run typeorm:migration:run
|
|
241
|
+
|
|
242
|
+
npm run typeorm:seed | npm run seed
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### MongoDB (Mongoose)
|
|
246
|
+
|
|
247
|
+
1. Make sure MongoDB is running (local or Docker).
|
|
248
|
+
2. Update `.env` if necessary:
|
|
249
|
+
|
|
250
|
+
```env
|
|
251
|
+
MONGO_URI=mongodb://<user>:<password>@localhost:27017/blog_demo
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
3. Run the seed script (if present):
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
npm run seed
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 4️⃣ Run the Project
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
cd blog-demo
|
|
266
|
+
npm install
|
|
267
|
+
npm run start:dev
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
- Swagger UI available (if enabled): [http://localhost:3000/api/docs](http://localhost:3000/api/docs)
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## 5️⃣ Main Endpoints
|
|
275
|
+
|
|
276
|
+
- **Auth** (if enabled):
|
|
277
|
+
- POST `/auth/register` → Create an account
|
|
278
|
+
- POST `/auth/login` → Log in
|
|
279
|
+
- **Users**: `/users`
|
|
280
|
+
- **Posts**: `/posts`
|
|
281
|
+
- **Comments**: `/comments`
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## 6️⃣ Tips
|
|
286
|
+
|
|
287
|
+
- Edit the `.env` file to connect to your own database.
|
|
288
|
+
- Run the seed to populate the database with sample data.
|
|
289
|
+
- The project is ready to launch immediately after configuration.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
**NestCraftX v0.2.5** – Clean Architecture Generator for NestJS
|
|
294
|
+
[Complete Documentation](https://github.com/august-dev-pro/NestCraftX)
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025-2026 Augustin Selete
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Augustin Selete
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|