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.
Files changed (63) hide show
  1. package/.gitattributes +6 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  4. package/.github/ISSUE_TEMPLATE/pull_request_template.md +24 -0
  5. package/CHANGELOG.fr.md +97 -97
  6. package/CHANGELOG.md +98 -98
  7. package/CLI_USAGE.fr.md +331 -331
  8. package/CLI_USAGE.md +364 -364
  9. package/DEMO.fr.md +292 -292
  10. package/DEMO.md +294 -294
  11. package/LICENSE +21 -21
  12. package/MIGRATION_GUIDE.fr.md +127 -127
  13. package/MIGRATION_GUIDE.md +124 -124
  14. package/QUICK_START.fr.md +152 -152
  15. package/QUICK_START.md +169 -169
  16. package/README.fr.md +653 -659
  17. package/SECURITY.md +10 -0
  18. package/bin/nestcraft.js +84 -64
  19. package/commands/demo.js +333 -330
  20. package/commands/generate.js +93 -0
  21. package/commands/generateConf.js +91 -0
  22. package/commands/help.js +78 -78
  23. package/commands/info.js +48 -48
  24. package/commands/new.js +338 -335
  25. package/commands/start.js +19 -19
  26. package/commands/test.js +7 -7
  27. package/package.json +41 -41
  28. package/readme.md +638 -643
  29. package/utils/cliParser.js +133 -76
  30. package/utils/colors.js +62 -62
  31. package/utils/configs/configureDocker.js +120 -120
  32. package/utils/configs/setupCleanArchitecture.js +563 -557
  33. package/utils/configs/setupLightArchitecture.js +701 -660
  34. package/utils/envGenerator.js +122 -122
  35. package/utils/file-utils/packageJsonUtils.js +49 -55
  36. package/utils/file-utils/saveProjectConfig.js +36 -0
  37. package/utils/fullModeInput.js +607 -607
  38. package/utils/generators/application/dtoUpdater.js +54 -0
  39. package/utils/generators/cleanModuleGenerator.js +475 -0
  40. package/utils/generators/database/setupDatabase.js +31 -0
  41. package/utils/generators/domain/entityUpdater.js +78 -0
  42. package/utils/generators/infrastructure/mapperUpdater.js +65 -0
  43. package/utils/generators/lightModuleGenerator.js +131 -0
  44. package/utils/generators/relation/relation.engine.js +64 -0
  45. package/utils/interactive/askEntityInputs.js +165 -0
  46. package/utils/lightModeInput.js +460 -460
  47. package/utils/loggers/logError.js +7 -7
  48. package/utils/loggers/logInfo.js +7 -7
  49. package/utils/loggers/logSuccess.js +7 -7
  50. package/utils/loggers/logWarning.js +7 -7
  51. package/utils/setups/orms/typeOrmSetup.js +630 -630
  52. package/utils/setups/projectSetup.js +46 -46
  53. package/utils/setups/setupAuth.js +973 -926
  54. package/utils/setups/setupDatabase.js +75 -75
  55. package/utils/setups/setupLogger.js +69 -59
  56. package/utils/setups/setupMongoose.js +377 -432
  57. package/utils/setups/setupPrisma.js +802 -630
  58. package/utils/setups/setupSwagger.js +97 -88
  59. package/utils/shell.js +32 -32
  60. package/utils/spinner.js +57 -57
  61. package/utils/systemCheck.js +124 -124
  62. package/utils/userInput.js +421 -421
  63. package/utils/utils.js +2197 -1762
package/readme.md CHANGED
@@ -1,643 +1,638 @@
1
- ## NestCraftX — Clean Architecture Generator for NestJS
2
-
3
- ![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
4
- ![Node.js](https://img.shields.io/badge/node-%3E=14.0.0-green.svg)
5
- ![Version](https://img.shields.io/badge/version-0.2.3-brightgreen.svg)
6
- ![Prisma](https://img.shields.io/badge/ORM-Prisma-lightblue)
7
- ![TypeORM](https://img.shields.io/badge/ORM-TypeORM-red)
8
- ![Mongoose](https://img.shields.io/badge/ORM-Mongoose-pink)
9
-
10
- **NestCraftX** is a modern and powerful Node.js CLI for automatically generating NestJS projects and content with a clean, maintainable, and production-ready architecture.
11
-
12
- It scaffolds everything you need to get started:
13
-
14
- - Modules, Controllers & Services (Fully typed)
15
- - Repositories & Mappers (For clean data flow and separation of concerns)
16
- - DTOs (With built-in validation)
17
- - Entities / Schemas (Prisma, TypeORM, or Mongoose)
18
- - Authentication (JWT with Refresh Tokens & auto-generated secrets)
19
- - DevOps Ready (Docker, Docker-Compose & Swagger UI)
20
-
21
- It implements modern best practices: **Clean Architecture**, **Domain-Driven Design (DDD)**, **Prisma/TypeORM/Mongoose**, **JWT Auth with auto-generated secrets**, **Swagger**, **Docker**, and much more.
22
-
23
- Key Features:
24
-
25
- - Dual-Architecture: Choose between Light (MVP) or Full (Clean Architecture / DDD).
26
-
27
- - Interactive Relations: Define 1-N or N-N relationships directly in the terminal.
28
-
29
- - Smart Config: Automated Swagger decorators, auto-documented .env files, and pre-configured database connections.
30
-
31
- > Version 0.2.3: Major improvement - Interactive demo with flags, Auth refactored via UserService, professional templates (gitignore, README), clean code maintained by the community!
32
-
33
- ---
34
-
35
- ## Table of Contents
36
-
37
- - [What's New in v0.2.3](#whats-new-in-v023)
38
- - [Project Objective](#project-objective)
39
- - [Prerequisites](#prerequisites)
40
- - [Installation](#installation)
41
- - [Available Commands](#available-commands)
42
- - [Features](#features)
43
- - [Generated Architecture](#generated-architecture)
44
- - [Complete Demo](#complete-demo)
45
- - [Usage Guide](#usage-guide)
46
- - [Roadmap](#roadmap)
47
- - [Contributing](#contributing)
48
- - [License](#license)
49
-
50
- ---
51
-
52
- ## What's New in v0.2.3
53
-
54
- ### Two Architecture Modes
55
-
56
- **FULL Mode - Complete Architecture**
57
-
58
- - Clean Architecture with use-cases, mappers, adapters
59
- - Strict separation: domain/application/infrastructure/presentation
60
- - Ideal for complex and scalable projects
61
-
62
- **LIGHT Mode - MVP Architecture**
63
-
64
- - Simplified structure: controllers → services → repositories
65
- - Quick start for prototypes
66
- - Perfect for small projects and MVPs
67
-
68
- ### Improved Demo Command
69
-
70
- - ✅ Flag options: `--light`, `--orm`, `--auth`, `--swagger`, `--docker`
71
- - Interactive mode: only asks questions for missing flags
72
- - ✅ Intelligent merging of flags and interactive responses
73
- - ✅ 3 pre-configured entities with relationships
74
- - ✅ Support for all ORMs (Prisma, TypeORM, Mongoose)
75
- - ✅ Separate instructions in [Demo Documentation](./DEMO.md)
76
-
77
- ### Modern CLI with Flags
78
-
79
- ```bash
80
- nestcraftx new <project-name> [options]
81
-
82
- Options:
83
- --light Simplified architecture mode
84
- --full Complete architecture mode (default)
85
- --db=<db> Database choice: postgresql|mongodb
86
- --orm=<orm> ORM choice: prisma|typeorm|mongoose
87
- --auth Enable JWT authentication
88
- --swagger Enable Swagger documentation
89
- --docker Enable Docker (default: true)
90
- ```
91
-
92
- ### Automatic Secret Generation
93
-
94
- - Auto-generated JWT secrets (64 secure characters)
95
- - Ready-to-use .env file
96
- - DATABASE_URL automatically configured
97
- - Sanitized .env.example file
98
-
99
- ### Improved UX
100
-
101
- - Colored messages (info, success, error)
102
- - Animated spinners for long operations
103
- - Detailed post-generation summary
104
- - Real-time validation of options
105
-
106
- ### Quick Examples
107
-
108
- ```bash
109
- # LIGHT project with Prisma and Auth
110
- nestcraftx new my-api --light --orm=prisma --auth
111
-
112
- # FULL project with TypeORM and Swagger
113
- nestcraftx new my-project --full --orm=typeorm --swagger
114
-
115
- # Minimal MongoDB project
116
- nestcraftx new my-api --light --orm=mongoose
117
- ```
118
-
119
- ---
120
-
121
- ## Project Objective
122
-
123
- Stop wasting time configuring your backend architecture. NestCraftX allows you to:
124
-
125
- - ✅ Start a project in minutes instead of days
126
- - Have a Clean Architecture from the start
127
- - ✅ Standardize your projects with the same best practices
128
- - ✅ Automatically configure DB-ORM and other modules (decorators, authentication, dockerization)
129
- - ✅ Focus on business logic
130
- - ✅ Choose between quick configuration (Light) or complete (Full)
131
-
132
- ## Prerequisites
133
-
134
- Make sure you have:
135
-
136
- - **Node.js** v14 or higher
137
- - **npm** or **yarn**
138
- - **Nest CLI** (optional, will be used via npx)
139
- - **Docker** (optional, for containerization)
140
- - **Git** (optional, for version control)
141
-
142
- Verify your environment with:
143
-
144
- ```bash
145
- nestcraftx test
146
- ```
147
-
148
- ---
149
-
150
- ## Installation
151
-
152
- ### Via npx (recommended)
153
-
154
- Use NestCraftX without global installation:
155
-
156
- ```bash
157
- npx nestcraftx new my-app
158
- ```
159
-
160
- ### Global Installation
161
-
162
- For frequent use:
163
-
164
- ```bash
165
- npm install -g nestcraftx
166
- nestcraftx new my-app
167
- ```
168
-
169
- ### Installation for Development
170
-
171
- ```bash
172
- git clone https://github.com/august-dev-pro/NestCraftX.git
173
- cd NestCraftX
174
- npm install
175
- npm link
176
- ```
177
-
178
- ---
179
-
180
- ## Available Commands
181
-
182
- ### `nestcraftx new <project-name> [options]`
183
-
184
- Creates a new NestJS project with Clean Architecture.
185
-
186
- **Options:**
187
-
188
- - `--light` : Quick configuration mode
189
- - `--orm <prisma|typeorm|mongoose>` : ORM choice
190
- - `--auth` : Add JWT authentication
191
- - `--swagger` : Add Swagger UI
192
- - `--docker` : Generate Docker files
193
-
194
- **Examples:**
195
-
196
- ```bash
197
- # Full interactive mode
198
- nestcraftx new my-app
199
-
200
- # Quick mode with options
201
- nestcraftx new blog-api --light --orm=prisma --auth --swagger
202
-
203
- # Custom configuration
204
- nestcraftx new shop --orm=typeorm --auth
205
- ```
206
-
207
- ### `nestcraftx demo [options]`
208
-
209
- Generates a complete demonstration project (blog-demo) with:
210
-
211
- - 3 entities (User, Post, Comment) with 1-n relationships
212
- - Integrated JWT Auth
213
- - Swagger enabled
214
- - Docker configured
215
-
216
- **Options:**
217
-
218
- - `--light` : Simplified architecture mode
219
- - `--docker` : Enable Docker (default: true)
220
- - `--auth` : Enable JWT Auth (default: true)
221
- - `--swagger` : Enable Swagger (default: true)
222
- - `--orm <prisma|typeorm|mongoose>` : ORM choice (default: prisma)
223
-
224
- **Examples:**
225
-
226
- ```bash
227
- # Interactive mode (will ask questions)
228
- nestcraftx demo
229
-
230
- # LIGHT mode with Mongoose
231
- nestcraftx demo --light --orm=mongoose
232
-
233
- # FULL mode with TypeORM
234
- nestcraftx demo --orm=typeorm --auth --swagger
235
-
236
- # Quick start
237
- nestcraftx demo --light --orm=prisma
238
- ```
239
-
240
- **Result:**
241
-
242
- A functional blog project with:
243
-
244
- - Blog-demo created
245
- - 3 complete entities
246
- - Relationships between User → Post → Comment
247
- - Auth endpoints (register, login) ready
248
- - Business endpoints: /users, /posts, /comments ready
249
- - Automatic Swagger documentation
250
- - Docker & Docker Compose configured
251
- - ORM configuration of your choice (Prisma, TypeORM, Mongoose)
252
-
253
- ### `nestcraftx test`
254
-
255
- Checks if your environment is ready:
256
-
257
- ```bash
258
- nestcraftx test
259
- ```
260
-
261
- Displays the status of Node, npm, Nest CLI, Docker, Git, etc.
262
-
263
- ### `nestcraftx info`
264
-
265
- Displays CLI information:
266
-
267
- ```bash
268
- nestcraftx info
269
- ```
270
-
271
- ---
272
-
273
- ## Features
274
-
275
- ### Architecture
276
-
277
- ✅ **Clean Architecture** with domain/application/infrastructure/presentation separation
278
- **Domain-Driven Design** with entities, use cases and repositories
279
- ✅ **Repository Pattern** for persistence abstraction
280
- ✅ **Use Cases Pattern** for isolated business logic
281
- ✅ **Mapper Pattern** for data transformation
282
-
283
- ### Database
284
-
285
- ✅ **Prisma ➡️ (PostgreSQL)** - Modern and type-safe ORM (recommended)
286
-
287
- ✅ **TypeORM ➡️ (PostgreSQL)** - Complete ORM with decorators
288
-
289
- ✅ **Mongoose ➡️ (MongoDB)** - ODM for MongoDB (Coming soon)
290
-
291
- ✅ Automatic schema configuration
292
-
293
- ✅ PostgreSQL and MongoDB support
294
-
295
- ### Security
296
-
297
- ✅ **JWT Authentication** with guards and strategies
298
-
299
- ✅ **Role-based Access Control** (RBAC)
300
-
301
- ✅ **Password hashing** with bcrypt
302
-
303
- ✅ **Public routes** with decorators
304
-
305
- ### Documentation
306
-
307
- ✅ **Swagger UI** automatic
308
-
309
- ✅ ApiProperty decorators on DTOs
310
-
311
- ✅ Endpoint documentation
312
-
313
- ✅ Interactive API interface
314
-
315
- ### DevOps
316
-
317
- ✅ **Docker** and **Docker Compose**
318
-
319
- ✅ Environment variables configuration
320
-
321
- ✅ Structured logging
322
-
323
- ✅ Centralized error handling
324
-
325
- ### Code Quality
326
-
327
- ✅ DTO validation with class-validator
328
-
329
- ✅ Data transformation with class-transformer
330
-
331
- ✅ Standardized response interceptors
332
-
333
- ✅ Global exception filters
334
-
335
- ---
336
-
337
- ## Generated Architecture
338
-
339
- ### Light Mode (MVP)
340
-
341
- ```
342
- src
343
- ├── auth
344
- │ ├── controllers
345
- │ │ └── auth.controller.ts
346
- ├── dtos
347
- ├── create-session.dto.ts
348
- │ │ ├── forgotPassword.dto.ts
349
- ├── loginCredential.dto.ts
350
- │ │ ├── refreshToken.dto.ts
351
- │ │ ├── resetPassword.dto.ts
352
- │ │ ├── sendOtp.dto.ts
353
- │ │ └── verifyOtp.dto.ts
354
- │ ├── entities
355
- │ │ └── session.entity.ts
356
- ├── guards
357
- ├── jwt-auth.guard.ts
358
- │ │ └── role.guard.ts
359
- │ ├── mappers
360
- │ │ └── session.mapper.ts
361
- ├── persistence
362
- │ └── session.repository.ts
363
- ├── services
364
- ├── auth.service.ts
365
- │ │ └── session.service.ts
366
- │ ├── strategies
367
- │ │ └── jwt.strategy.ts
368
- │ └── auth.module.ts
369
-
370
- ├── common
371
- ├── decorators
372
- │ ├── current-user.decorator.ts
373
- │ │ ├── public.decorator.ts
374
- │ └── role.decorator.ts
375
- │ ├── enums
376
- │ │ └── role.enum.ts
377
- ├── filters
378
- │ └── all-exceptions.filter.ts
379
- ├── interceptors
380
- │ └── response.interceptor.ts
381
- │ └── middlewares
382
- └── logger.middleware.ts
383
-
384
- ├── prisma
385
- ├── prisma.module.ts
386
- └── prisma.service.ts
387
-
388
- ├── user
389
- ├── controllers
390
- │ └── user.controller.ts
391
- ├── dtos
392
- │ └── user.dto.ts
393
- ├── entities
394
- │ └── user.entity.ts
395
- ├── repositories
396
- │ └── user.repository.ts
397
- ├── services
398
- │ └── user.service.ts
399
- │ └── user.module.ts
400
-
401
- ├── app.controller.spec.ts
402
- ├── app.controller.ts
403
- ├── app.module.ts
404
- ├── app.service.ts
405
- └── main.ts
406
- ```
407
-
408
- ### Full Mode (Clean Architecture)
409
-
410
- ```
411
- src
412
- ├── auth
413
- │ ├── controllers
414
- │ │ └── auth.controller.ts
415
- ├── dtos
416
- ├── create-session.dto.ts
417
- │ │ ├── forgotPassword.dto.ts
418
- ├── loginCredential.dto.ts
419
- │ │ ├── refreshToken.dto.ts
420
- │ │ ├── resetPassword.dto.ts
421
- │ │ ├── sendOtp.dto.ts
422
- │ │ └── verifyOtp.dto.ts
423
- │ ├── entities
424
- │ │ └── session.entity.ts
425
- ├── guards
426
- ├── jwt-auth.guard.ts
427
- │ │ └── role.guard.ts
428
- │ ├── mappers
429
- │ │ └── session.mapper.ts
430
- ├── persistence
431
- │ └── session.repository.ts
432
- ├── services
433
- ├── auth.service.ts
434
- │ │ └── session.service.ts
435
- │ ├── strategies
436
- │ │ └── jwt.strategy.ts
437
- │ └── auth.module.ts
438
-
439
- ├── common
440
- ├── decorators
441
- │ ├── current-user.decorator.ts
442
- │ │ ├── public.decorator.ts
443
- │ └── role.decorator.ts
444
- │ ├── enums
445
- │ │ └── role.enum.ts
446
- ├── filters
447
- │ └── all-exceptions.filter.ts
448
- ├── interceptors
449
- │ └── response.interceptor.ts
450
- │ └── middlewares
451
- └── logger.middleware.ts
452
-
453
- ├── prisma
454
- ├── prisma.module.ts
455
- └── prisma.service.ts
456
-
457
- ├── user
458
- ├── controllers
459
- │ └── user.controller.ts
460
- ├── dtos
461
- │ └── user.dto.ts
462
- ├── entities
463
- │ └── user.entity.ts
464
- ├── repositories
465
- │ └── user.repository.ts
466
- ├── services
467
- │ └── user.service.ts
468
- │ └── user.module.ts
469
-
470
- ├── app.controller.spec.ts
471
- ├── app.controller.ts
472
- ├── app.module.ts
473
- ├── app.service.ts
474
- └── main.ts
475
- ```
476
-
477
- ## Complete Demo
478
-
479
- 🔥 A ready-to-run demo, including 3 linked entities, JWT Auth, Swagger, Docker and configurable ORM.
480
-
481
- 👉 See full documentation: [Demo Documentation](./DEMO.md)
482
-
483
- ## Usage Guide
484
-
485
- ### Quick Start (Light Mode)
486
-
487
- ```bash
488
- # 1. Create a simple project
489
- npx nestcraftx new my-api --light --orm prisma
490
-
491
- # 2. Navigate to the project
492
- cd my-api
493
-
494
- # 3. Start the application
495
- npm run start:dev
496
- ```
497
-
498
- ### Complete Configuration (Full Mode)
499
-
500
- ```bash
501
- # 1. Launch with interactive interface
502
- npx nestcraftx new my-project
503
-
504
- # 2. Answer the questions:
505
- # - Project name
506
- # - Database choice
507
- # - ORM configuration
508
- # - Entities and relationships
509
- # - Auth and Swagger
510
-
511
- # 3. Start
512
- cd my-project
513
- npm run start:dev
514
- ```
515
-
516
- ### Demonstration Project
517
-
518
- ```bash
519
- # Generate a complete blog project (interactive mode)
520
- nestcraftx demo
521
-
522
- # Or with direct options
523
- nestcraftx demo --light --orm prisma --auth --swagger
524
-
525
- # Navigate and start
526
- cd blog-demo
527
- npm run start:dev
528
-
529
- # Access Swagger UI
530
- open http://localhost:3000/api/docs
531
- ```
532
-
533
- **What the demo project includes:**
534
-
535
- - Complete Clean Architecture (or LIGHT depending on option)
536
- - 3 pre-configured entities: User, Post, Comment
537
- - Relationships between entities (User → Post, Post ↔ Comment)
538
- - JWT Auth with /auth/register and /auth/login endpoints
539
- - Business endpoints: /users, /posts, /comments
540
- - Automatic Swagger documentation
541
- - Docker & Docker Compose configured
542
- - ORM configuration of your choice (Prisma, TypeORM, Mongoose)
543
-
544
- ---
545
-
546
- ## Roadmap
547
-
548
- ### Version 0.2.x (Current Focus)
549
-
550
- - [x] Light & Full Architecture engines.
551
-
552
- - [x] Inquirer.js interactive prompts.
553
-
554
- - [ ] Stability: Deep testing for Prisma, TypeORM and Mongoose integrations.
555
-
556
- - [ ] Documentation: Complete API examples in README.
557
-
558
- ### Version 0.3.0 (Expansion)
559
-
560
- - [ ] New Databases: Full support for MySQL and SQLite.
561
-
562
- - [ ] Scaffolding: generate command to add new modules/entities to an existing project.
563
-
564
- - [ ] Testing: Automated unit test generation for services and controllers.
565
-
566
- ### Version 0.5.0 (Enterprise Features)
567
-
568
- - [ ] Redis Integration: Choice of session management (Redis, Map, or Database).
569
-
570
- - [ ] CI/CD: Ready-to-use templates for GitHub Actions and GitLab CI.
571
-
572
- - [ ] Seeding: Advanced database seeding generation.
573
-
574
- ### Version 1.0.0 (The Milestone)
575
-
576
- - [ ] Microservices: Support for hybrid applications and microservices.
577
-
578
- - [ ] Web UI: Optional visual interface for project configuration.
579
-
580
- - [ ] Community: Official documentation site and plugin system.
581
-
582
- ---
583
-
584
- ## Contributing
585
-
586
- Want to improve NestCraftX? Contributions are welcome!
587
-
588
- ### How to Contribute
589
-
590
- 1. Fork the project
591
- 2. Create a branch for your feature (`git checkout -b feature/AmazingFeature`)
592
- 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
593
- 4. Push to the branch (`git push origin feature/AmazingFeature`)
594
- 5. Open a Pull Request
595
-
596
- ### Open an Issue
597
-
598
- Found bugs? Have ideas? Open an issue on GitHub!
599
-
600
- ### Developers
601
-
602
- To develop locally:
603
-
604
- ```bash
605
- git clone https://github.com/august-dev-pro/NestCraftX.git
606
- cd NestCraftX
607
- npm install
608
- npm link
609
- ```
610
-
611
- ---
612
-
613
- ## License
614
-
615
- MIT © [Ablanhou Augustin Selete](https://github.com/august-dev-pro)
616
-
617
- Free for personal and commercial use.
618
-
619
- ---
620
-
621
- ## Thanks
622
-
623
- Thanks to all contributors and the NestJS community!
624
-
625
- **Made with ❤️ for the backend developer community**
626
-
627
- ---
628
-
629
- ## Contact & Support
630
-
631
- - 📧 GitHub Issues: [Open an issue](https://github.com/august-dev-pro/NestCraftX/issues)
632
- - 🌐 Repository: [NestCraftX on GitHub](https://github.com/august-dev-pro/NestCraftX)
633
- - ⭐ If this project helps you, please consider giving it a star!
634
-
635
- ---
636
-
637
- **NestCraftX v0.2.3** - Clean Architecture Made Simple
638
-
639
- For more information:
640
-
641
- - [Complete Usage Guide](./CLI_USAGE.md)
642
- - [Migration Guide](./MIGRATION_GUIDE.md)
643
- - [Detailed Changelog](./CHANGELOG.md)
1
+ # NestCraftX — Clean Architecture Generator for NestJS
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/nestcraftx?style=flat-square&color=CB3837)](https://www.npmjs.com/package/nestcraftx)
4
+ [![NPM Downloads](https://img.shields.io/npm/dm/nestcraftx?style=flat-square&color=51a2da)](https://www.npmjs.com/package/nestcraftx)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
6
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D14.0.0-4dc71f?style=flat-square)](https://nodejs.org)
7
+
8
+ **ORMs:**
9
+ ![Prisma](https://img.shields.io/badge/Prisma-2D3748?style=flat-square&logo=prisma&logoColor=white)
10
+ ![TypeORM](https://img.shields.io/badge/TypeORM-FE0803?style=flat-square&logo=typeorm&logoColor=white)
11
+ ![Mongoose](https://img.shields.io/badge/Mongoose-880000?style=flat-square&logo=mongodb&logoColor=green)
12
+
13
+ **NestCraftX** is a modern and powerful Node.js CLI for automatically generating NestJS projects and content with a clean, maintainable, and production-ready architecture.
14
+
15
+ It scaffolds everything you need to get started:
16
+
17
+ - Modules, Controllers & Services (Fully typed)
18
+ - Repositories & Mappers (For clean data flow and separation of concerns)
19
+ - DTOs (With built-in validation)
20
+ - Entities / Schemas (Prisma, TypeORM, or Mongoose)
21
+ - Authentication (JWT with Refresh Tokens & auto-generated secrets)
22
+ - DevOps Ready (Docker, Docker-Compose & Swagger UI)
23
+
24
+ It implements modern best practices: **Clean Architecture**, **Domain-Driven Design (DDD)**, **Prisma/TypeORM/Mongoose**, **JWT Auth with auto-generated secrets**, **Swagger**, **Docker**, and much more.
25
+
26
+ Key Features:
27
+
28
+ - Dual-Architecture: Choose between Light (MVP) or Full (Clean Architecture / DDD).
29
+
30
+ - Interactive Relations: Define 1-N or N-N relationships directly in the terminal.
31
+
32
+ - Smart Config: Automated Swagger decorators, auto-documented .env files, and pre-configured database connections.
33
+
34
+ > **Version 0.2.5:** Major release — Interactive generation via flags, Auth refactored with session management, professional templates (gitignore, README), and clean code standards maintained by the community!
35
+
36
+ ---
37
+
38
+ ## Table of Contents
39
+
40
+ - [What's New in v0.2.5](#whats-new-in-v025)
41
+ - [Project Objective](#project-objective)
42
+ - [Prerequisites](#prerequisites)
43
+ - [Installation](#installation)
44
+ - [Available Commands](#available-commands)
45
+ - [Features](#features)
46
+ - [Generated Architecture](#generated-architecture)
47
+ - [Complete Demo](#complete-demo)
48
+ - [Usage Guide](#usage-guide)
49
+ - [Roadmap](#roadmap)
50
+ - [Contributing](#contributing)
51
+ - [License](#license)
52
+
53
+ ---
54
+
55
+ ## What's New in v0.2.5
56
+
57
+ ### Two Architecture Modes
58
+
59
+ **FULL Mode - Complete Architecture**
60
+
61
+ - Clean Architecture with use-cases, mappers, adapters
62
+ - Strict separation: domain/application/infrastructure/presentation
63
+ - Ideal for complex and scalable projects
64
+
65
+ **LIGHT Mode - MVP Architecture**
66
+
67
+ - Simplified structure: controllers → services → repositories
68
+ - Quick start for prototypes
69
+ - Perfect for small projects and MVPs
70
+
71
+ ### Improved Demo Command
72
+
73
+ - ✅ Flag options: `--light`, `--orm`, `--auth`, `--swagger`, `--docker`
74
+ - ✅ Interactive mode: only asks questions for missing flags
75
+ - ✅ Intelligent merging of flags and interactive responses
76
+ - ✅ 3 pre-configured entities with relationships
77
+ - Support for all ORMs (Prisma, TypeORM, Mongoose)
78
+ - ✅ Separate instructions in [Demo Documentation](./DEMO.md)
79
+
80
+ ### Modern CLI with Flags
81
+
82
+ ```bash
83
+ nestcraftx new <project-name> [options]
84
+
85
+ Options:
86
+ --light Simplified architecture mode
87
+ --full Complete architecture mode (default)
88
+ --db=<db> Database choice: postgresql|mongodb
89
+ --orm=<orm> ORM choice: prisma|typeorm|mongoose
90
+ --auth Enable JWT authentication
91
+ --swagger Enable Swagger documentation
92
+ --docker Enable Docker (default: true)
93
+ ```
94
+
95
+ ### Automatic Secret Generation
96
+
97
+ - Auto-generated JWT secrets (64 secure characters)
98
+ - Ready-to-use .env file
99
+ - DATABASE_URL automatically configured
100
+ - Sanitized .env.example file
101
+
102
+ ### Improved UX
103
+
104
+ - Colored messages (info, success, error)
105
+ - Animated spinners for long operations
106
+ - Detailed post-generation summary
107
+ - Real-time validation of options
108
+
109
+ ### Quick Examples
110
+
111
+ ```bash
112
+ # LIGHT project with Prisma and Auth
113
+ nestcraftx new my-api --light --orm=prisma --auth
114
+
115
+ # FULL project with TypeORM and Swagger
116
+ nestcraftx new my-project --full --orm=typeorm --swagger
117
+
118
+ # Minimal MongoDB project
119
+ nestcraftx new my-api --light --orm=mongoose
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Project Objective
125
+
126
+ Stop wasting time configuring your backend architecture. NestCraftX allows you to:
127
+
128
+ - ✅ Start a project in minutes instead of days
129
+ - ✅ Have a Clean Architecture from the start
130
+ - ✅ Standardize your projects with the same best practices
131
+ - ✅ Automatically configure DB-ORM and other modules (decorators, authentication, dockerization)
132
+ - ✅ Focus on business logic
133
+ - ✅ Choose between quick configuration (Light) or complete (Full)
134
+
135
+ ## Prerequisites
136
+
137
+ Make sure you have:
138
+
139
+ - **Node.js** v14 or higher
140
+ - **npm** or **yarn**
141
+ - **Nest CLI** (optional, will be used via npx)
142
+ - **Docker** (optional, for containerization)
143
+ - **Git** (optional, for version control)
144
+
145
+ Verify your environment with:
146
+
147
+ ```bash
148
+ nestcraftx test
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Installation
154
+
155
+ ### Via npx (recommended)
156
+
157
+ Use NestCraftX without global installation:
158
+
159
+ ```bash
160
+ npx nestcraftx new my-app
161
+ ```
162
+
163
+ ### Global Installation
164
+
165
+ For frequent use:
166
+
167
+ ```bash
168
+ npm install -g nestcraftx
169
+ nestcraftx new my-app
170
+ ```
171
+
172
+ ### Installation for Development
173
+
174
+ ```bash
175
+ git clone https://github.com/august-dev-pro/NestCraftX.git
176
+ cd NestCraftX
177
+ npm install
178
+ npm link
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Available Commands
184
+
185
+ ### `nestcraftx new <project-name> [options]`
186
+
187
+ Creates a new NestJS project with Clean Architecture.
188
+
189
+ **Options:**
190
+
191
+ - `--light` : Quick configuration mode
192
+ - `--orm <prisma|typeorm|mongoose>` : ORM choice
193
+ - `--auth` : Add JWT authentication
194
+ - `--swagger` : Add Swagger UI
195
+ - `--docker` : Generate Docker files
196
+
197
+ **Examples:**
198
+
199
+ ```bash
200
+ # Full interactive mode
201
+ nestcraftx new my-app
202
+
203
+ # Quick mode with options
204
+ nestcraftx new blog-api --light --orm=prisma --auth --swagger
205
+
206
+ # Custom configuration
207
+ nestcraftx new shop --orm=typeorm --auth
208
+ ```
209
+
210
+ ### `nestcraftx demo [options]`
211
+
212
+ Generates a complete demonstration project (blog-demo) with:
213
+
214
+ - 3 entities (User, Post, Comment) with 1-n relationships
215
+ - Integrated JWT Auth
216
+ - Swagger enabled
217
+ - Docker configured
218
+
219
+ **Options:**
220
+
221
+ - `--light` : Simplified architecture mode
222
+ - `--docker` : Enable Docker (default: true)
223
+ - `--auth` : Enable JWT Auth (default: true)
224
+ - `--swagger` : Enable Swagger (default: true)
225
+ - `--orm <prisma|typeorm|mongoose>` : ORM choice (default: prisma)
226
+
227
+ **Examples:**
228
+
229
+ ```bash
230
+ # Interactive mode (will ask questions)
231
+ nestcraftx demo
232
+
233
+ # LIGHT mode with Mongoose
234
+ nestcraftx demo --light --orm=mongoose
235
+
236
+ # FULL mode with TypeORM
237
+ nestcraftx demo --orm=typeorm --auth --swagger
238
+
239
+ # Quick start
240
+ nestcraftx demo --light --orm=prisma
241
+ ```
242
+
243
+ **Result:**
244
+
245
+ A functional blog project with:
246
+
247
+ - Blog-demo created
248
+ - 3 complete entities
249
+ - Relationships between User → Post → Comment
250
+ - Auth endpoints (register, login) ready
251
+ - Business endpoints: /users, /posts, /comments ready
252
+ - Automatic Swagger documentation
253
+ - Docker & Docker Compose configured
254
+ - ORM configuration of your choice (Prisma, TypeORM, Mongoose)
255
+
256
+ ### `nestcraftx test`
257
+
258
+ Checks if your environment is ready:
259
+
260
+ ```bash
261
+ nestcraftx test
262
+ ```
263
+
264
+ Displays the status of Node, npm, Nest CLI, Docker, Git, etc.
265
+
266
+ ### `nestcraftx info`
267
+
268
+ Displays CLI information:
269
+
270
+ ```bash
271
+ nestcraftx info
272
+ ```
273
+
274
+ ---
275
+
276
+ ## Features
277
+
278
+ ### Architecture
279
+
280
+ ✅ **Clean Architecture** with domain/application/infrastructure/presentation separation
281
+ ✅ **Domain-Driven Design** with entities, use cases and repositories
282
+ ✅ **Repository Pattern** for persistence abstraction
283
+ **Use Cases Pattern** for isolated business logic
284
+ ✅ **Mapper Pattern** for data transformation
285
+
286
+ ### Database
287
+
288
+ ✅ **Prisma ➡️ (PostgreSQL)** - Modern and type-safe ORM (recommended)
289
+
290
+ ✅ **TypeORM ➡️ (PostgreSQL)** - Complete ORM with decorators
291
+
292
+ ✅ **Mongoose ➡️ (MongoDB)** - ODM for MongoDB
293
+
294
+ ✅ Automatic schema configuration
295
+
296
+ ✅ PostgreSQL and MongoDB support
297
+
298
+ ### Security
299
+
300
+ ✅ **JWT Authentication** with guards and strategies
301
+
302
+ ✅ **Role-based Access Control** (RBAC)
303
+
304
+ ✅ **Password hashing** with bcrypt
305
+
306
+ ✅ **Public routes** with decorators
307
+
308
+ ### Documentation
309
+
310
+ ✅ **Swagger UI** automatic
311
+
312
+ ✅ ApiProperty decorators on DTOs
313
+
314
+ ✅ Endpoint documentation
315
+
316
+ ✅ Interactive API interface
317
+
318
+ ### DevOps
319
+
320
+ ✅ **Docker** and **Docker Compose**
321
+
322
+ ✅ Environment variables configuration
323
+
324
+ ✅ Structured logging
325
+
326
+ ✅ Centralized error handling
327
+
328
+ ### Code Quality
329
+
330
+ ✅ DTO validation with class-validator
331
+
332
+ ✅ Data transformation with class-transformer
333
+
334
+ ✅ Standardized response interceptors
335
+
336
+ ✅ Global exception filters
337
+
338
+ ---
339
+
340
+ ## Generated Architecture
341
+
342
+ ### Light Mode (MVP)
343
+
344
+ ```
345
+ src
346
+ ├── auth
347
+ │ ├── controllers
348
+ │ │ └── auth.controller.ts
349
+ │ ├── dtos
350
+ │ │ ├── create-session.dto.ts
351
+ │ │ ├── forgotPassword.dto.ts
352
+ │ │ ├── loginCredential.dto.ts
353
+ │ │ ├── refreshToken.dto.ts
354
+ ├── resetPassword.dto.ts
355
+ │ │ ├── sendOtp.dto.ts
356
+ │ └── verifyOtp.dto.ts
357
+ │ ├── entities
358
+ │ │ └── session.entity.ts
359
+ │ ├── guards
360
+ │ │ ├── jwt-auth.guard.ts
361
+ │ └── role.guard.ts
362
+ ├── mappers
363
+ │ └── session.mapper.ts
364
+ │ ├── persistence
365
+ │ │ └── session.repository.ts
366
+ │ ├── services
367
+ │ │ ├── auth.service.ts
368
+ └── session.service.ts
369
+ ├── strategies
370
+ │ │ └── jwt.strategy.ts
371
+ └── auth.module.ts
372
+
373
+ ├── common
374
+ ├── decorators
375
+ ├── current-user.decorator.ts
376
+ │ │ ├── public.decorator.ts
377
+ │ └── role.decorator.ts
378
+ ├── enums
379
+ │ └── role.enum.ts
380
+ ├── filters
381
+ └── all-exceptions.filter.ts
382
+ ├── interceptors
383
+ │ └── response.interceptor.ts
384
+ │ └── middlewares
385
+ └── logger.middleware.ts
386
+
387
+ ├── prisma
388
+ ├── prisma.module.ts
389
+ └── prisma.service.ts
390
+
391
+ ├── user
392
+ ├── controllers
393
+ │ └── user.controller.ts
394
+ ├── dtos
395
+ │ └── user.dto.ts
396
+ ├── entities
397
+ │ └── user.entity.ts
398
+ ├── repositories
399
+ └── user.repository.ts
400
+ ├── services
401
+ │ │ └── user.service.ts
402
+ │ └── user.module.ts
403
+
404
+ ├── app.controller.spec.ts
405
+ ├── app.controller.ts
406
+ ├── app.module.ts
407
+ ├── app.service.ts
408
+ └── main.ts
409
+ ```
410
+
411
+ ### Full Mode (Clean Architecture)
412
+
413
+ ```
414
+ src
415
+ ├── auth
416
+ │ ├── controllers
417
+ │ │ └── auth.controller.ts
418
+ │ ├── dtos
419
+ │ │ ├── create-session.dto.ts
420
+ │ │ ├── forgotPassword.dto.ts
421
+ │ │ ├── loginCredential.dto.ts
422
+ │ │ ├── refreshToken.dto.ts
423
+ ├── resetPassword.dto.ts
424
+ │ │ ├── sendOtp.dto.ts
425
+ │ └── verifyOtp.dto.ts
426
+ │ ├── entities
427
+ │ │ └── session.entity.ts
428
+ │ ├── guards
429
+ │ │ ├── jwt-auth.guard.ts
430
+ │ └── role.guard.ts
431
+ ├── mappers
432
+ │ └── session.mapper.ts
433
+ │ ├── persistence
434
+ │ │ └── session.repository.ts
435
+ │ ├── services
436
+ │ │ ├── auth.service.ts
437
+ └── session.service.ts
438
+ ├── strategies
439
+ │ │ └── jwt.strategy.ts
440
+ └── auth.module.ts
441
+
442
+ ├── common
443
+ ├── decorators
444
+ ├── current-user.decorator.ts
445
+ │ │ ├── public.decorator.ts
446
+ │ └── role.decorator.ts
447
+ ├── enums
448
+ │ └── role.enum.ts
449
+ ├── filters
450
+ └── all-exceptions.filter.ts
451
+ ├── interceptors
452
+ │ └── response.interceptor.ts
453
+ │ └── middlewares
454
+ └── logger.middleware.ts
455
+
456
+ ├── prisma
457
+ ├── prisma.module.ts
458
+ └── prisma.service.ts
459
+
460
+ ├── user
461
+ ├── controllers
462
+ │ └── user.controller.ts
463
+ ├── dtos
464
+ │ └── user.dto.ts
465
+ ├── entities
466
+ │ └── user.entity.ts
467
+ ├── repositories
468
+ └── user.repository.ts
469
+ ├── services
470
+ │ │ └── user.service.ts
471
+ │ └── user.module.ts
472
+
473
+ ├── app.controller.spec.ts
474
+ ├── app.controller.ts
475
+ ├── app.module.ts
476
+ ├── app.service.ts
477
+ └── main.ts
478
+ ```
479
+
480
+ ## Complete Demo
481
+
482
+ 🔥 A ready-to-run demo, including 3 linked entities, JWT Auth, Swagger, Docker and configurable ORM.
483
+
484
+ 👉 See full documentation: [Demo Documentation](./DEMO.md)
485
+
486
+ ## Usage Guide
487
+
488
+ ### Quick Start (Light Mode)
489
+
490
+ ```bash
491
+ # 1. Create a simple project
492
+ npx nestcraftx new my-api --light --orm prisma
493
+
494
+ # 2. Navigate to the project
495
+ cd my-api
496
+
497
+ # 3. Start the application
498
+ npm run start:dev
499
+ ```
500
+
501
+ ### Complete Configuration (Full Mode)
502
+
503
+ ```bash
504
+ # 1. Launch with interactive interface
505
+ npx nestcraftx new my-project
506
+
507
+ # 2. Answer the questions:
508
+ # - Project name
509
+ # - Database choice
510
+ # - ORM configuration
511
+ # - Entities and relationships
512
+ # - Auth and Swagger
513
+
514
+ # 3. Start
515
+ cd my-project
516
+ npm run start:dev
517
+ ```
518
+
519
+ ### Demonstration Project
520
+
521
+ ```bash
522
+ # Generate a complete blog project (interactive mode)
523
+ nestcraftx demo
524
+
525
+ # Or with direct options
526
+ nestcraftx demo --light --orm prisma --auth --swagger
527
+
528
+ # Navigate and start
529
+ cd blog-demo
530
+ npm run start:dev
531
+
532
+ # Access Swagger UI
533
+ open http://localhost:3000/api/docs
534
+ ```
535
+
536
+ **What the demo project includes:**
537
+
538
+ - Complete Clean Architecture (or LIGHT depending on option)
539
+ - 3 pre-configured entities: User, Post, Comment
540
+ - Relationships between entities (User → Post, Post ↔ Comment)
541
+ - JWT Auth with /auth/register and /auth/login endpoints
542
+ - Business endpoints: /users, /posts, /comments
543
+ - Automatic Swagger documentation
544
+ - Docker & Docker Compose configured
545
+ - ORM configuration of your choice (Prisma, TypeORM, Mongoose)
546
+
547
+ ---
548
+
549
+ ## Roadmap
550
+
551
+ ### Version 0.2.x — Stabilization
552
+
553
+ - [x] Light & Full architectures
554
+ - [x] Interactive CLI
555
+ - [x] Multi-ORM support (Prisma / TypeORM / Mongoose)
556
+ - [ ] Comprehensive documentation & realistic examples
557
+
558
+ ### Version 0.3.0 — Developer Experience
559
+
560
+ - [ ] `generate` command (scaffold modules/entities into existing projects)
561
+ - [ ] SQLite support for zero-config demos & prototyping
562
+ - [ ] Enhanced error handling & colored terminal logs
563
+
564
+ ### Version 0.4.0 Production Readiness
565
+
566
+ - [ ] Pluggable session strategies (In-memory / Database / Redis)
567
+ - [ ] Advanced data seeding templates
568
+ - [ ] Project presets (API Only / Auth / Full CRUD)
569
+
570
+ ### Version 1.0.0 Stable Release
571
+
572
+ - [ ] TypeScript-native CLI
573
+ - [ ] Enforced conventions & stable API contracts
574
+ - [ ] Official documentation website
575
+ - [ ] Long-term support (LTS) guarantees
576
+
577
+ ---
578
+
579
+ ## Contributing
580
+
581
+ Want to improve NestCraftX? Contributions are welcome!
582
+
583
+ ### How to Contribute
584
+
585
+ 1. Fork the project
586
+ 2. Create a branch for your feature (`git checkout -b feature/AmazingFeature`)
587
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
588
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
589
+ 5. Open a Pull Request
590
+
591
+ ### Open an Issue
592
+
593
+ Found bugs? Have ideas? Open an issue on GitHub!
594
+
595
+ ### Developers
596
+
597
+ To develop locally:
598
+
599
+ ```bash
600
+ git clone https://github.com/august-dev-pro/NestCraftX.git
601
+ cd NestCraftX
602
+ npm install
603
+ npm link
604
+ ```
605
+
606
+ ---
607
+
608
+ ## License
609
+
610
+ MIT © [Ablanhou Augustin Selete](https://github.com/august-dev-pro)
611
+
612
+ Free for personal and commercial use.
613
+
614
+ ---
615
+
616
+ ## Thanks
617
+
618
+ Thanks to all contributors and the NestJS community!
619
+
620
+ **Made with ❤️ for the backend developer community**
621
+
622
+ ---
623
+
624
+ ## Contact & Support
625
+
626
+ - 📧 GitHub Issues: [Open an issue](https://github.com/august-dev-pro/NestCraftX/issues)
627
+ - 🌐 Repository: [NestCraftX on GitHub](https://github.com/august-dev-pro/NestCraftX)
628
+ - ⭐ If this project helps you, please consider giving it a star!
629
+
630
+ ---
631
+
632
+ **NestCraftX v0.2.5** - Clean Architecture Made Simple
633
+
634
+ For more information:
635
+
636
+ - [Complete Usage Guide](./CLI_USAGE.md)
637
+ - [Migration Guide](./MIGRATION_GUIDE.md)
638
+ - [Detailed Changelog](./CHANGELOG.md)