nestjs-ddd-cli 2.2.1 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -408
- package/ddd.schema.json +111 -0
- package/dist/commands/aggregate-validator.d.ts +9 -0
- package/dist/commands/aggregate-validator.js +953 -0
- package/dist/commands/aggregate-validator.js.map +1 -0
- package/dist/commands/ai-assist.d.ts +8 -0
- package/dist/commands/ai-assist.js +337 -0
- package/dist/commands/ai-assist.js.map +1 -0
- package/dist/commands/api-contracts.d.ts +9 -0
- package/dist/commands/api-contracts.js +1368 -0
- package/dist/commands/api-contracts.js.map +1 -0
- package/dist/commands/api-docs.d.ts +8 -0
- package/dist/commands/api-docs.js +408 -0
- package/dist/commands/api-docs.js.map +1 -0
- package/dist/commands/api-versioning.d.ts +11 -0
- package/dist/commands/api-versioning.js +643 -0
- package/dist/commands/api-versioning.js.map +1 -0
- package/dist/commands/audit-logging.d.ts +9 -0
- package/dist/commands/audit-logging.js +1129 -0
- package/dist/commands/audit-logging.js.map +1 -0
- package/dist/commands/batch-generate.d.ts +10 -0
- package/dist/commands/batch-generate.js +405 -0
- package/dist/commands/batch-generate.js.map +1 -0
- package/dist/commands/caching-strategies.d.ts +9 -0
- package/dist/commands/caching-strategies.js +874 -0
- package/dist/commands/caching-strategies.js.map +1 -0
- package/dist/commands/code-analyzer.d.ts +42 -0
- package/dist/commands/code-analyzer.js +474 -0
- package/dist/commands/code-analyzer.js.map +1 -0
- package/dist/commands/database-seeding.d.ts +6 -0
- package/dist/commands/database-seeding.js +621 -0
- package/dist/commands/database-seeding.js.map +1 -0
- package/dist/commands/db-optimization.d.ts +7 -0
- package/dist/commands/db-optimization.js +687 -0
- package/dist/commands/db-optimization.js.map +1 -0
- package/dist/commands/dependency-graph.d.ts +6 -0
- package/dist/commands/dependency-graph.js +329 -0
- package/dist/commands/dependency-graph.js.map +1 -0
- package/dist/commands/doctor-enhanced.d.ts +22 -0
- package/dist/commands/doctor-enhanced.js +543 -0
- package/dist/commands/doctor-enhanced.js.map +1 -0
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.js +151 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/env-manager.d.ts +6 -0
- package/dist/commands/env-manager.js +419 -0
- package/dist/commands/env-manager.js.map +1 -0
- package/dist/commands/event-sourcing-full.d.ts +10 -0
- package/dist/commands/event-sourcing-full.js +1107 -0
- package/dist/commands/event-sourcing-full.js.map +1 -0
- package/dist/commands/feature-flags.d.ts +9 -0
- package/dist/commands/feature-flags.js +824 -0
- package/dist/commands/feature-flags.js.map +1 -0
- package/dist/commands/filter-dsl.d.ts +10 -0
- package/dist/commands/filter-dsl.js +1407 -0
- package/dist/commands/filter-dsl.js.map +1 -0
- package/dist/commands/generate-all.js +485 -32
- package/dist/commands/generate-all.js.map +1 -1
- package/dist/commands/generate-deployment.d.ts +8 -0
- package/dist/commands/generate-deployment.js +746 -0
- package/dist/commands/generate-deployment.js.map +1 -0
- package/dist/commands/generate-domain-service.d.ts +14 -0
- package/dist/commands/generate-domain-service.js +796 -0
- package/dist/commands/generate-domain-service.js.map +1 -0
- package/dist/commands/generate-entity.js +82 -24
- package/dist/commands/generate-entity.js.map +1 -1
- package/dist/commands/generate-from-schema.d.ts +56 -0
- package/dist/commands/generate-from-schema.js +222 -0
- package/dist/commands/generate-from-schema.js.map +1 -0
- package/dist/commands/generate-orchestrator.d.ts +14 -0
- package/dist/commands/generate-orchestrator.js +887 -0
- package/dist/commands/generate-orchestrator.js.map +1 -0
- package/dist/commands/generate-repository.d.ts +14 -0
- package/dist/commands/generate-repository.js +1019 -0
- package/dist/commands/generate-repository.js.map +1 -0
- package/dist/commands/generate-shared.d.ts +4 -0
- package/dist/commands/generate-shared.js +388 -0
- package/dist/commands/generate-shared.js.map +1 -0
- package/dist/commands/generate-value-object.d.ts +32 -0
- package/dist/commands/generate-value-object.js +700 -0
- package/dist/commands/generate-value-object.js.map +1 -0
- package/dist/commands/graphql-subscriptions.d.ts +6 -0
- package/dist/commands/graphql-subscriptions.js +607 -0
- package/dist/commands/graphql-subscriptions.js.map +1 -0
- package/dist/commands/graphql-types.d.ts +5 -0
- package/dist/commands/graphql-types.js +423 -0
- package/dist/commands/graphql-types.js.map +1 -0
- package/dist/commands/health-probes-advanced.d.ts +6 -0
- package/dist/commands/health-probes-advanced.js +655 -0
- package/dist/commands/health-probes-advanced.js.map +1 -0
- package/dist/commands/i18n-setup.d.ts +10 -0
- package/dist/commands/i18n-setup.js +677 -0
- package/dist/commands/i18n-setup.js.map +1 -0
- package/dist/commands/init-config.d.ts +6 -0
- package/dist/commands/init-config.js +370 -0
- package/dist/commands/init-config.js.map +1 -0
- package/dist/commands/init-project.js +56 -6
- package/dist/commands/init-project.js.map +1 -1
- package/dist/commands/interactive-scaffold.d.ts +5 -0
- package/dist/commands/interactive-scaffold.js +271 -0
- package/dist/commands/interactive-scaffold.js.map +1 -0
- package/dist/commands/metrics-prometheus.d.ts +6 -0
- package/dist/commands/metrics-prometheus.js +681 -0
- package/dist/commands/metrics-prometheus.js.map +1 -0
- package/dist/commands/migration-engine.d.ts +6 -0
- package/dist/commands/migration-engine.js +446 -0
- package/dist/commands/migration-engine.js.map +1 -0
- package/dist/commands/migration.d.ts +12 -0
- package/dist/commands/migration.js +484 -0
- package/dist/commands/migration.js.map +1 -0
- package/dist/commands/monorepo.d.ts +8 -0
- package/dist/commands/monorepo.js +483 -0
- package/dist/commands/monorepo.js.map +1 -0
- package/dist/commands/multi-database.d.ts +5 -0
- package/dist/commands/multi-database.js +439 -0
- package/dist/commands/multi-database.js.map +1 -0
- package/dist/commands/observability-tracing.d.ts +10 -0
- package/dist/commands/observability-tracing.js +740 -0
- package/dist/commands/observability-tracing.js.map +1 -0
- package/dist/commands/openapi-export.d.ts +8 -0
- package/dist/commands/openapi-export.js +359 -0
- package/dist/commands/openapi-export.js.map +1 -0
- package/dist/commands/perf-analyzer.d.ts +8 -0
- package/dist/commands/perf-analyzer.js +423 -0
- package/dist/commands/perf-analyzer.js.map +1 -0
- package/dist/commands/rate-limiting.d.ts +10 -0
- package/dist/commands/rate-limiting.js +953 -0
- package/dist/commands/rate-limiting.js.map +1 -0
- package/dist/commands/recipe-plugin.d.ts +56 -0
- package/dist/commands/recipe-plugin.js +315 -0
- package/dist/commands/recipe-plugin.js.map +1 -0
- package/dist/commands/recipe.d.ts +6 -0
- package/dist/commands/recipe.js +3941 -0
- package/dist/commands/recipe.js.map +1 -0
- package/dist/commands/recipes/elasticsearch.recipe.d.ts +1 -0
- package/dist/commands/recipes/elasticsearch.recipe.js +761 -0
- package/dist/commands/recipes/elasticsearch.recipe.js.map +1 -0
- package/dist/commands/recipes/event-sourcing.recipe.d.ts +1 -0
- package/dist/commands/recipes/event-sourcing.recipe.js +889 -0
- package/dist/commands/recipes/event-sourcing.recipe.js.map +1 -0
- package/dist/commands/recipes/index.d.ts +7 -0
- package/dist/commands/recipes/index.js +24 -0
- package/dist/commands/recipes/index.js.map +1 -0
- package/dist/commands/recipes/message-queue.recipe.d.ts +1 -0
- package/dist/commands/recipes/message-queue.recipe.js +706 -0
- package/dist/commands/recipes/message-queue.recipe.js.map +1 -0
- package/dist/commands/recipes/middleware.recipe.d.ts +1 -0
- package/dist/commands/recipes/middleware.recipe.js +383 -0
- package/dist/commands/recipes/middleware.recipe.js.map +1 -0
- package/dist/commands/recipes/multi-tenancy.recipe.d.ts +1 -0
- package/dist/commands/recipes/multi-tenancy.recipe.js +520 -0
- package/dist/commands/recipes/multi-tenancy.recipe.js.map +1 -0
- package/dist/commands/recipes/oauth2.recipe.d.ts +1 -0
- package/dist/commands/recipes/oauth2.recipe.js +472 -0
- package/dist/commands/recipes/oauth2.recipe.js.map +1 -0
- package/dist/commands/recipes/websocket.recipe.d.ts +1 -0
- package/dist/commands/recipes/websocket.recipe.js +453 -0
- package/dist/commands/recipes/websocket.recipe.js.map +1 -0
- package/dist/commands/resilience-patterns.d.ts +13 -0
- package/dist/commands/resilience-patterns.js +1029 -0
- package/dist/commands/resilience-patterns.js.map +1 -0
- package/dist/commands/security-patterns.d.ts +11 -0
- package/dist/commands/security-patterns.js +2233 -0
- package/dist/commands/security-patterns.js.map +1 -0
- package/dist/commands/template-debug.d.ts +27 -0
- package/dist/commands/template-debug.js +388 -0
- package/dist/commands/template-debug.js.map +1 -0
- package/dist/commands/test-factory-full.d.ts +9 -0
- package/dist/commands/test-factory-full.js +1570 -0
- package/dist/commands/test-factory-full.js.map +1 -0
- package/dist/commands/test-scaffold.d.ts +7 -0
- package/dist/commands/test-scaffold.js +621 -0
- package/dist/commands/test-scaffold.js.map +1 -0
- package/dist/index.js +1088 -0
- package/dist/index.js.map +1 -1
- package/dist/templates/ai-context/CLAUDE.md.hbs +158 -0
- package/dist/templates/ai-context/conventions.md.hbs +154 -0
- package/dist/templates/command/create-command.hbs +6 -14
- package/dist/templates/command/delete-command.hbs +19 -0
- package/dist/templates/command/update-command.hbs +24 -0
- package/dist/templates/controller/controller.hbs +64 -17
- package/dist/templates/dto/create-dto.hbs +29 -5
- package/dist/templates/dto/filter-dto.hbs +52 -0
- package/dist/templates/dto/filter-query.dto.hbs +148 -0
- package/dist/templates/dto/paginated-response.dto.hbs +29 -0
- package/dist/templates/dto/pagination-query.dto.hbs +30 -0
- package/dist/templates/dto/response-dto.hbs +38 -0
- package/dist/templates/dto/update-dto.hbs +11 -0
- package/dist/templates/entity/entity.hbs +32 -1
- package/dist/templates/event/domain-event.hbs +33 -7
- package/dist/templates/event/event-handler.hbs +40 -0
- package/dist/templates/exception/base-exceptions.hbs +69 -0
- package/dist/templates/exception/entity-not-found.exception.hbs +7 -0
- package/dist/templates/mapper/mapper.hbs +49 -24
- package/dist/templates/module/module.hbs +34 -10
- package/dist/templates/orm-entity/orm-entity.hbs +63 -12
- package/dist/templates/prisma/prisma-mapper.hbs +71 -0
- package/dist/templates/prisma/prisma-repository.hbs +114 -0
- package/dist/templates/prisma/prisma-schema.hbs +20 -0
- package/dist/templates/prisma/prisma-service.hbs +51 -0
- package/dist/templates/query/get-all.query.hbs +50 -0
- package/dist/templates/query/get-by-id.query.hbs +31 -0
- package/dist/templates/repository/repository.hbs +55 -13
- package/dist/templates/resolver/graphql-input.hbs +54 -0
- package/dist/templates/resolver/graphql-type.hbs +58 -0
- package/dist/templates/resolver/pagination-args.hbs +33 -0
- package/dist/templates/resolver/resolver.hbs +62 -0
- package/dist/templates/shared/prisma-query-builder.util.hbs +189 -0
- package/dist/templates/shared/query-builder.util.hbs +218 -0
- package/dist/templates/test/controller.spec.hbs +124 -0
- package/dist/templates/test/repository.spec.hbs +158 -0
- package/dist/templates/test/usecase.spec.hbs +116 -0
- package/dist/templates/usecase/create-usecase.hbs +19 -7
- package/dist/templates/usecase/delete-usecase.hbs +17 -0
- package/dist/templates/usecase/update-usecase.hbs +31 -0
- package/dist/utils/config.utils.d.ts +45 -0
- package/dist/utils/config.utils.js +211 -0
- package/dist/utils/config.utils.js.map +1 -0
- package/dist/utils/error.utils.d.ts +145 -0
- package/dist/utils/error.utils.js +422 -0
- package/dist/utils/error.utils.js.map +1 -0
- package/dist/utils/field.utils.d.ts +54 -0
- package/dist/utils/field.utils.js +389 -0
- package/dist/utils/field.utils.js.map +1 -0
- package/dist/utils/file.utils.d.ts +19 -8
- package/dist/utils/file.utils.js +135 -4
- package/dist/utils/file.utils.js.map +1 -1
- package/dist/utils/idempotency.utils.d.ts +123 -0
- package/dist/utils/idempotency.utils.js +444 -0
- package/dist/utils/idempotency.utils.js.map +1 -0
- package/dist/utils/naming.utils.js +24 -5
- package/dist/utils/naming.utils.js.map +1 -1
- package/dist/utils/performance.utils.d.ts +37 -0
- package/dist/utils/performance.utils.js +158 -0
- package/dist/utils/performance.utils.js.map +1 -0
- package/dist/utils/relation.utils.d.ts +92 -0
- package/dist/utils/relation.utils.js +388 -0
- package/dist/utils/relation.utils.js.map +1 -0
- package/dist/utils/rollback.utils.d.ts +49 -0
- package/dist/utils/rollback.utils.js +306 -0
- package/dist/utils/rollback.utils.js.map +1 -0
- package/dist/utils/schema.utils.d.ts +123 -0
- package/dist/utils/schema.utils.js +419 -0
- package/dist/utils/schema.utils.js.map +1 -0
- package/dist/utils/security.utils.d.ts +57 -0
- package/dist/utils/security.utils.js +315 -0
- package/dist/utils/security.utils.js.map +1 -0
- package/dist/utils/template-engine.utils.d.ts +80 -0
- package/dist/utils/template-engine.utils.js +463 -0
- package/dist/utils/template-engine.utils.js.map +1 -0
- package/dist/utils/validation-registry.utils.d.ts +160 -0
- package/dist/utils/validation-registry.utils.js +526 -0
- package/dist/utils/validation-registry.utils.js.map +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,506 +1,345 @@
|
|
|
1
1
|
# NestJS DDD CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**An opinionated CLI for pragmatic Domain-Driven Design with NestJS**
|
|
4
4
|
|
|
5
5
|
Stop writing boilerplate. Start building business logic.
|
|
6
6
|
|
|
7
|
-
Generate production-ready NestJS code following proven DDD/CQRS patterns with consistent structure and immutable architecture principles.
|
|
7
|
+
Generate production-ready, security-hardened NestJS code following proven DDD/CQRS patterns with consistent structure and immutable architecture principles.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
9
|
+
## What's New in v3.2
|
|
10
|
+
|
|
11
|
+
- **Security-Hardened Generation**: 25 security iterations following OWASP Top 10
|
|
12
|
+
- **Enterprise Patterns**: Circuit breaker, distributed tracing, feature flags
|
|
13
|
+
- **Advanced Caching**: Cache-aside, write-through, invalidation strategies
|
|
14
|
+
- **Observability**: OpenTelemetry tracing, Prometheus metrics, Grafana dashboards
|
|
15
|
+
- **Database Optimization**: DataLoader, query analysis, connection pooling
|
|
16
|
+
- **Kubernetes-Ready**: Health probes, graceful shutdown, liveness/readiness
|
|
17
|
+
- **GraphQL Subscriptions**: Real-time with PubSub and connection management
|
|
13
18
|
|
|
14
19
|
## Installation
|
|
15
20
|
|
|
16
|
-
**From NPM (Recommended):**
|
|
17
21
|
```bash
|
|
18
22
|
npm install -g nestjs-ddd-cli
|
|
19
23
|
```
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
git clone https://github.com/eshe-huli/nestjs-ddd-cli
|
|
24
|
-
cd nestjs-ddd-cli
|
|
25
|
-
npm install
|
|
26
|
-
npm run build
|
|
27
|
-
npm link
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
|
-
|
|
32
|
-
### Initialize a New NestJS Project
|
|
33
|
-
|
|
34
|
-
Create a new NestJS project with DDD structure:
|
|
25
|
+
## Quick Start
|
|
35
26
|
|
|
36
27
|
```bash
|
|
28
|
+
# Initialize a new project
|
|
37
29
|
ddd init my-project
|
|
38
|
-
```
|
|
39
30
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- `--skip-install` - Skip dependency installation
|
|
43
|
-
- `--skip-update` - Skip CLI update check
|
|
44
|
-
- `--with-ddd` - Set up DDD folder structure and install required dependencies (default: true)
|
|
31
|
+
# Generate complete CRUD with typed fields
|
|
32
|
+
ddd scaffold User -m users --fields "name:string email:string:unique age:number:optional"
|
|
45
33
|
|
|
46
|
-
|
|
34
|
+
# Apply authentication recipe
|
|
35
|
+
ddd recipe auth-jwt --install-deps
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
# Set up security patterns
|
|
38
|
+
ddd security-patterns
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
ddd
|
|
40
|
+
# Add observability
|
|
41
|
+
ddd observability
|
|
52
42
|
```
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
- `-f, --force` - Force update even if already on latest version
|
|
44
|
+
## Commands
|
|
56
45
|
|
|
57
|
-
###
|
|
46
|
+
### Core Commands
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
ddd
|
|
63
|
-
|
|
48
|
+
| Command | Description |
|
|
49
|
+
|---------|-------------|
|
|
50
|
+
| `ddd init <name>` | Initialize new NestJS project with DDD structure |
|
|
51
|
+
| `ddd scaffold <entity> -m <module>` | Generate complete CRUD with all layers |
|
|
52
|
+
| `ddd generate <type> <name> -m <module>` | Generate individual components |
|
|
53
|
+
| `ddd recipe [name]` | Apply common patterns (auth, caching, etc.) |
|
|
54
|
+
| `ddd shared` | Generate shared utilities and base classes |
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
- `-p, --path <path>` - Path to the project (default: current directory)
|
|
67
|
-
- `-a, --all` - Update all outdated dependencies without prompting
|
|
56
|
+
### Enterprise Commands
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
| Command | Description |
|
|
59
|
+
|---------|-------------|
|
|
60
|
+
| `ddd security-patterns` | RBAC, encryption, OWASP middleware, JWT security |
|
|
61
|
+
| `ddd circuit-breaker` | Resilience patterns (retry, timeout, fallback) |
|
|
62
|
+
| `ddd observability` | OpenTelemetry distributed tracing |
|
|
63
|
+
| `ddd feature-flags` | Feature flags with A/B testing support |
|
|
64
|
+
| `ddd caching-advanced` | Multi-layer caching strategies |
|
|
65
|
+
| `ddd db-optimization` | DataLoader, query analyzer, connection pooling |
|
|
66
|
+
| `ddd database-seeding` | Seed runner with fixture factories |
|
|
67
|
+
| `ddd health-probes` | Kubernetes liveness/readiness/startup probes |
|
|
68
|
+
| `ddd metrics-prometheus` | Prometheus metrics with Grafana dashboard |
|
|
69
|
+
| `ddd graphql-subscriptions` | Real-time GraphQL with PubSub |
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
### Utility Commands
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
| Command | Description |
|
|
74
|
+
|---------|-------------|
|
|
75
|
+
| `ddd update` | Update CLI to latest version |
|
|
76
|
+
| `ddd update-deps` | Update project dependencies |
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
- `-m, --module <module>` - Module name (will be created if not exists)
|
|
79
|
-
- `-p, --path <path>` - Base path for generation
|
|
80
|
-
- `--install-deps` - Install required dependencies
|
|
78
|
+
## Field-Aware Generation
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
Generate complete typed entities, DTOs, and migrations:
|
|
83
81
|
|
|
84
82
|
```bash
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
# Generate an entity
|
|
89
|
-
ddd generate entity User -m user-management
|
|
90
|
-
|
|
91
|
-
# Generate a use case
|
|
92
|
-
ddd generate usecase CreateUser -m user-management
|
|
83
|
+
ddd scaffold Product -m inventory --fields "name:string price:number:optional sku:string:unique"
|
|
84
|
+
```
|
|
93
85
|
|
|
94
|
-
|
|
95
|
-
ddd generate service UserValidation -m user-management
|
|
86
|
+
**Field Format:** `name:type:modifier1:modifier2`
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
| Types | Modifiers |
|
|
89
|
+
|-------|-----------|
|
|
90
|
+
| `string`, `text` | `optional` |
|
|
91
|
+
| `number`, `int`, `float`, `decimal` | `unique` |
|
|
92
|
+
| `boolean` | `relation` |
|
|
93
|
+
| `date`, `datetime`, `timestamp` | `OneToOne`, `OneToMany`, `ManyToOne`, `ManyToMany` |
|
|
94
|
+
| `uuid`, `json`, `enum` | |
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
**Relations:**
|
|
97
|
+
```bash
|
|
98
|
+
# ManyToOne relation
|
|
99
|
+
ddd scaffold Order -m orders --fields "customer:relation:Customer:ManyToOne"
|
|
102
100
|
|
|
103
|
-
#
|
|
104
|
-
ddd
|
|
101
|
+
# OneToMany relation
|
|
102
|
+
ddd scaffold Customer -m customers --fields "orders:relation:Order:OneToMany:customer"
|
|
105
103
|
```
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
- `-m, --module <name>`: Specify the module name
|
|
110
|
-
- `-p, --path <path>`: Base path for generation (defaults to current directory)
|
|
111
|
-
- `--skip-orm`: Skip ORM entity generation
|
|
112
|
-
- `--skip-mapper`: Skip mapper generation
|
|
113
|
-
- `--skip-repo`: Skip repository generation
|
|
114
|
-
- `--with-events`: Include domain events
|
|
115
|
-
- `--with-queries`: Include query handlers
|
|
116
|
-
|
|
117
|
-
## Available Generators
|
|
118
|
-
|
|
119
|
-
| Generator | Command | Description |
|
|
120
|
-
|-----------|---------|-------------|
|
|
121
|
-
| **Module** | `ddd generate module <name>` | Creates complete DDD module structure |
|
|
122
|
-
| **Entity** | `ddd generate entity <name> -m <module>` | Domain entity with ORM mapping |
|
|
123
|
-
| **Use Case** | `ddd generate usecase <name> -m <module>` | CQRS command handler |
|
|
124
|
-
| **Domain Service** | `ddd generate service <name> -m <module>` | Domain service for business logic |
|
|
125
|
-
| **Domain Event** | `ddd generate event <name> -m <module>` | Domain event for CQRS |
|
|
126
|
-
| **Query Handler** | `ddd generate query <name> -m <module>` | CQRS query handler |
|
|
127
|
-
| **Complete CRUD** | `ddd scaffold <name> -m <module>` | All files for an entity |
|
|
128
|
-
| **All Entity Files** | `ddd generate all <name> -m <module>` | Entity + related files |
|
|
105
|
+
## Security Features
|
|
129
106
|
|
|
130
|
-
|
|
107
|
+
The CLI generates security-hardened code following OWASP Top 10:
|
|
131
108
|
|
|
132
|
-
###
|
|
109
|
+
### Generated Security Patterns
|
|
133
110
|
|
|
134
111
|
```bash
|
|
135
|
-
|
|
136
|
-
ddd scaffold User -m user-management
|
|
137
|
-
|
|
138
|
-
# 2. Add business logic to the generated files
|
|
139
|
-
# 3. Update index.ts exports
|
|
140
|
-
# 4. Run migrations
|
|
141
|
-
# 5. Import module in app.module.ts
|
|
112
|
+
ddd security-patterns
|
|
142
113
|
```
|
|
143
114
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
│ │ └── 📁 usecases/
|
|
155
|
-
│ │ ├── 📄 create-user.usecase.ts ✅ Business logic for creation
|
|
156
|
-
│ │ ├── 📄 update-user.usecase.ts ✅ Business logic for updates
|
|
157
|
-
│ │ └── 📄 delete-user.usecase.ts ✅ Business logic for deletion
|
|
158
|
-
│ └── 📁 dto/
|
|
159
|
-
│ ├── 📁 requests/
|
|
160
|
-
│ │ ├── 📄 create-user.dto.ts ✅ Request validation schemas
|
|
161
|
-
│ │ └── 📄 update-user.dto.ts ✅ Update validation schemas
|
|
162
|
-
│ └── 📁 responses/
|
|
163
|
-
│ └── 📄 user.response.ts ✅ Response data contracts
|
|
164
|
-
└── 📁 infrastructure/
|
|
165
|
-
├── 📁 repositories/
|
|
166
|
-
│ └── 📄 user.repository.ts ✅ CRUD operations + custom queries
|
|
167
|
-
├── 📁 orm-entities/
|
|
168
|
-
│ └── 📄 user.orm-entity.ts ✅ Database schema (TypeORM)
|
|
169
|
-
└── 📁 mappers/
|
|
170
|
-
└── 📄 user.mapper.ts ✅ Domain ↔ Database mapping
|
|
171
|
-
```
|
|
115
|
+
Creates:
|
|
116
|
+
- **Encryption Service** - AES-256-GCM with PBKDF2 (600,000 iterations)
|
|
117
|
+
- **RBAC/ABAC Service** - Role and attribute-based access control
|
|
118
|
+
- **OWASP Middleware** - XSS, SQL injection, path traversal prevention
|
|
119
|
+
- **JWT Security** - Algorithm confusion prevention, claim validation
|
|
120
|
+
- **CORS Configuration** - Strict origin validation
|
|
121
|
+
- **Cookie Security** - HttpOnly, Secure, SameSite flags
|
|
122
|
+
- **Security Headers** - CSP, HSTS, X-Frame-Options, Permissions-Policy
|
|
123
|
+
- **Input Sanitizer** - HTML, shell, filename, URL sanitization
|
|
124
|
+
- **Secret Vault** - Encrypted secret storage with rotation
|
|
172
125
|
|
|
173
|
-
|
|
126
|
+
### Built-in Protections
|
|
174
127
|
|
|
175
|
-
|
|
128
|
+
- Path traversal prevention in all file operations
|
|
129
|
+
- Input validation with MaxLength on all string fields
|
|
130
|
+
- Sensitive data masking in logs (credit cards, SSN, tokens)
|
|
131
|
+
- Secure error handling (hides internals in production)
|
|
132
|
+
- Brute force detection with IP blocking
|
|
133
|
+
- CSRF token validation
|
|
176
134
|
|
|
177
|
-
|
|
135
|
+
## Recipes
|
|
178
136
|
|
|
179
137
|
```bash
|
|
180
|
-
#
|
|
181
|
-
ddd
|
|
182
|
-
|
|
183
|
-
# Add payment processing
|
|
184
|
-
ddd generate service PaymentProcessor -m orders
|
|
185
|
-
ddd generate event OrderPaid -m orders
|
|
186
|
-
|
|
187
|
-
# Add inventory checking
|
|
188
|
-
ddd generate query CheckStock -m inventory
|
|
189
|
-
ddd generate service StockValidator -m inventory
|
|
190
|
-
```
|
|
138
|
+
# List available recipes
|
|
139
|
+
ddd recipe
|
|
191
140
|
|
|
192
|
-
|
|
141
|
+
# Apply with dependency installation
|
|
142
|
+
ddd recipe auth-jwt --install-deps
|
|
193
143
|
```
|
|
194
|
-
📁 modules/orders/
|
|
195
|
-
├── 📄 orders.module.ts
|
|
196
|
-
├── 📁 application/domain/services/
|
|
197
|
-
│ └── 📄 payment-processor.service.ts 🆕 Payment business logic
|
|
198
|
-
├── 📁 application/domain/events/
|
|
199
|
-
│ └── 📄 order-paid.event.ts 🆕 Order payment event
|
|
200
|
-
└── ... (all CRUD operations)
|
|
201
|
-
|
|
202
|
-
📁 modules/inventory/
|
|
203
|
-
├── 📁 application/queries/
|
|
204
|
-
│ └── 📄 check-stock.handler.ts 🆕 Stock checking query
|
|
205
|
-
├── 📁 application/domain/services/
|
|
206
|
-
│ └── 📄 stock-validator.service.ts 🆕 Stock validation logic
|
|
207
|
-
└── ... (all CRUD operations)
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### 🏥 **Healthcare System**
|
|
211
144
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
145
|
+
| Recipe | Description |
|
|
146
|
+
|--------|-------------|
|
|
147
|
+
| `auth-jwt` | JWT authentication with guards and decorators |
|
|
148
|
+
| `pagination` | Shared pagination DTOs and utilities |
|
|
149
|
+
| `soft-delete` | Base entity and repository with soft delete |
|
|
150
|
+
| `audit-log` | Entity change tracking with sensitive data masking |
|
|
151
|
+
| `caching` | Redis caching with decorators |
|
|
215
152
|
|
|
216
|
-
|
|
217
|
-
ddd scaffold MedicalRecord -m medical-records
|
|
218
|
-
ddd generate event RecordCreated -m medical-records
|
|
219
|
-
ddd generate event RecordUpdated -m medical-records
|
|
153
|
+
## Generated Structure
|
|
220
154
|
|
|
221
|
-
# Appointment scheduling
|
|
222
|
-
ddd generate query FindAvailableSlots -m appointments
|
|
223
|
-
ddd generate service AppointmentScheduler -m appointments
|
|
224
155
|
```
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
|
|
156
|
+
src/
|
|
157
|
+
├── modules/
|
|
158
|
+
│ └── [module-name]/
|
|
159
|
+
│ ├── [module].module.ts
|
|
160
|
+
│ ├── application/
|
|
161
|
+
│ │ ├── commands/ # CQRS commands
|
|
162
|
+
│ │ ├── queries/ # CQRS queries (paginated)
|
|
163
|
+
│ │ ├── controllers/ # REST endpoints
|
|
164
|
+
│ │ └── dto/
|
|
165
|
+
│ │ ├── requests/ # Input DTOs with validation
|
|
166
|
+
│ │ └── responses/ # Output DTOs
|
|
167
|
+
│ └── domain/
|
|
168
|
+
│ ├── entities/ # Domain entities
|
|
169
|
+
│ ├── events/ # Domain events
|
|
170
|
+
│ ├── services/ # Domain services
|
|
171
|
+
│ └── usecases/ # Business logic
|
|
172
|
+
│ └── infrastructure/
|
|
173
|
+
│ ├── repositories/ # Data access
|
|
174
|
+
│ ├── orm-entities/ # Database schemas
|
|
175
|
+
│ └── mappers/ # Entity mapping
|
|
176
|
+
├── shared/
|
|
177
|
+
│ ├── security/ # Security services
|
|
178
|
+
│ ├── observability/ # Tracing, metrics
|
|
179
|
+
│ ├── resilience/ # Circuit breaker, retry
|
|
180
|
+
│ └── infrastructure/ # Base classes, utilities
|
|
181
|
+
└── migrations/
|
|
237
182
|
```
|
|
238
183
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
184
|
+
## Configuration
|
|
185
|
+
|
|
186
|
+
Create `.dddrc.json` in your project root:
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"$schema": "https://unpkg.com/nestjs-ddd-cli/ddd.schema.json",
|
|
191
|
+
"orm": "typeorm",
|
|
192
|
+
"database": "postgres",
|
|
193
|
+
"naming": {
|
|
194
|
+
"table": "snake_case",
|
|
195
|
+
"dto": "snake_case",
|
|
196
|
+
"file": "kebab-case"
|
|
197
|
+
},
|
|
198
|
+
"features": {
|
|
199
|
+
"swagger": true,
|
|
200
|
+
"pagination": true,
|
|
201
|
+
"softDelete": true,
|
|
202
|
+
"timestamps": true,
|
|
203
|
+
"tests": false,
|
|
204
|
+
"events": false
|
|
205
|
+
},
|
|
206
|
+
"paths": {
|
|
207
|
+
"modules": "src/modules",
|
|
208
|
+
"migrations": "src/migrations",
|
|
209
|
+
"shared": "src/shared"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
266
213
|
|
|
267
|
-
|
|
214
|
+
## Real-World Examples
|
|
268
215
|
|
|
269
|
-
|
|
216
|
+
### E-commerce with Security
|
|
270
217
|
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
│ │ ├── events/ # 🎯 Domain events
|
|
289
|
-
│ │ │ ├── [entity]-created.event.ts # └─ Event definitions
|
|
290
|
-
│ │ │ └── index.ts # └─ Barrel exports
|
|
291
|
-
│ │ ├── services/ # ⚙️ Domain services
|
|
292
|
-
│ │ │ ├── [entity].service.ts # └─ Business rules
|
|
293
|
-
│ │ │ └── index.ts # └─ Barrel exports
|
|
294
|
-
│ │ └── usecases/ # 🎬 Use case operations
|
|
295
|
-
│ │ ├── create-[entity].usecase.ts# └─ Create business logic
|
|
296
|
-
│ │ ├── update-[entity].usecase.ts# └─ Update business logic
|
|
297
|
-
│ │ ├── delete-[entity].usecase.ts# └─ Delete business logic
|
|
298
|
-
│ │ └── index.ts # └─ Barrel exports
|
|
299
|
-
│ ├── dto/ # 📄 Data contracts
|
|
300
|
-
│ │ ├── requests/ # 📤 Inbound data
|
|
301
|
-
│ │ │ ├── create-[entity].dto.ts # └─ Create request
|
|
302
|
-
│ │ │ ├── update-[entity].dto.ts # └─ Update request
|
|
303
|
-
│ │ │ └── index.ts # └─ Barrel exports
|
|
304
|
-
│ │ ├── responses/ # 📥 Outbound data
|
|
305
|
-
│ │ │ ├── [entity].response.ts # └─ Entity response
|
|
306
|
-
│ │ │ └── index.ts # └─ Barrel exports
|
|
307
|
-
│ │ └── index.ts # └─ Barrel exports
|
|
308
|
-
│ └── queries/ # 🔍 CQRS queries (reads)
|
|
309
|
-
│ ├── get-[entity].handler.ts # └─ Single entity query
|
|
310
|
-
│ ├── list-[entities].handler.ts # └─ Multiple entities query
|
|
311
|
-
│ └── index.ts # └─ Barrel exports
|
|
312
|
-
└── infrastructure/ # 🏗️ Infrastructure layer
|
|
313
|
-
├── mappers/ # 🔄 Data transformation
|
|
314
|
-
│ ├── [entity].mapper.ts # └─ Domain ↔ ORM mapping
|
|
315
|
-
│ └── index.ts # └─ Barrel exports
|
|
316
|
-
├── orm-entities/ # 🗄️ Database schema
|
|
317
|
-
│ ├── [entity].orm-entity.ts # └─ TypeORM entity
|
|
318
|
-
│ └── index.ts # └─ Barrel exports
|
|
319
|
-
└── repositories/ # 💾 Data access
|
|
320
|
-
├── [entity].repository.ts # └─ Repository implementation
|
|
321
|
-
└── index.ts # └─ Barrel exports
|
|
218
|
+
```bash
|
|
219
|
+
ddd init ecommerce-api
|
|
220
|
+
cd ecommerce-api
|
|
221
|
+
|
|
222
|
+
# Core security
|
|
223
|
+
ddd security-patterns
|
|
224
|
+
ddd recipe auth-jwt --install-deps
|
|
225
|
+
|
|
226
|
+
# Domain modules
|
|
227
|
+
ddd scaffold Product -m inventory --fields "name:string price:decimal sku:string:unique stock:int"
|
|
228
|
+
ddd scaffold Order -m orders --fields "total:decimal status:enum:pending,paid,shipped customerId:uuid"
|
|
229
|
+
ddd scaffold Customer -m customers --fields "email:string:unique name:string"
|
|
230
|
+
|
|
231
|
+
# Enterprise features
|
|
232
|
+
ddd circuit-breaker
|
|
233
|
+
ddd observability
|
|
234
|
+
ddd caching-advanced
|
|
322
235
|
```
|
|
323
236
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
### 🧠 **Smart Defaults & Conventions**
|
|
237
|
+
### Microservice with Observability
|
|
327
238
|
|
|
328
239
|
```bash
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
240
|
+
ddd init payment-service
|
|
241
|
+
cd payment-service
|
|
242
|
+
|
|
243
|
+
# Infrastructure
|
|
244
|
+
ddd security-patterns
|
|
245
|
+
ddd observability
|
|
246
|
+
ddd metrics-prometheus
|
|
247
|
+
ddd health-probes
|
|
248
|
+
|
|
249
|
+
# Domain
|
|
250
|
+
ddd scaffold Transaction -m payments --fields "amount:decimal currency:string status:enum:pending,completed,failed"
|
|
251
|
+
ddd circuit-breaker
|
|
333
252
|
```
|
|
334
253
|
|
|
335
|
-
|
|
336
|
-
- **🔄 Barrel exports** - Automatic `index.ts` files for clean imports
|
|
337
|
-
- **🔒 TypeScript strict** - Zero `any` types, full type safety
|
|
338
|
-
- **💉 DI ready** - Injectable decorators configured
|
|
339
|
-
- **📋 Interface first** - Clear contracts between layers
|
|
340
|
-
- **📁 Predictable paths** - Same location every time
|
|
341
|
-
|
|
342
|
-
### 💡 **Enterprise Patterns**
|
|
343
|
-
|
|
344
|
-
```typescript
|
|
345
|
-
// ✅ Commands (writes) - Tell, don't ask
|
|
346
|
-
@CommandHandler(CreateUserCommand)
|
|
347
|
-
export class CreateUserHandler {
|
|
348
|
-
async execute(command: CreateUserCommand): Promise<void> {
|
|
349
|
-
// Returns nothing - just does the work
|
|
350
|
-
}
|
|
351
|
-
}
|
|
254
|
+
### GraphQL API with Real-time
|
|
352
255
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
async execute(query: GetUserQuery): Promise<UserResponse> {
|
|
357
|
-
// Returns data - no side effects
|
|
358
|
-
}
|
|
359
|
-
}
|
|
256
|
+
```bash
|
|
257
|
+
ddd init realtime-api
|
|
258
|
+
cd realtime-api
|
|
360
259
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
260
|
+
ddd scaffold Message -m chat --fields "content:text senderId:uuid roomId:uuid"
|
|
261
|
+
ddd graphql-subscriptions
|
|
262
|
+
ddd caching-advanced
|
|
365
263
|
```
|
|
366
264
|
|
|
367
|
-
|
|
368
|
-
- **Command/Query Separation** - Writes vs reads clearly separated
|
|
369
|
-
- **Domain Events** - Decoupled communication between bounded contexts
|
|
370
|
-
- **Repository Pattern** - Abstract data access from business logic
|
|
371
|
-
- **Clean Architecture** - Dependencies point inward to domain
|
|
265
|
+
## AI Integration
|
|
372
266
|
|
|
373
|
-
|
|
267
|
+
The CLI generates a `CLAUDE.md` file with project context for AI assistants:
|
|
268
|
+
- Project structure documentation
|
|
269
|
+
- CLI command reference
|
|
270
|
+
- Naming conventions
|
|
271
|
+
- Architecture rules
|
|
272
|
+
- Security patterns
|
|
273
|
+
- Common patterns
|
|
374
274
|
|
|
375
|
-
|
|
275
|
+
## API Conventions
|
|
376
276
|
|
|
377
|
-
|
|
378
|
-
# ✅ 1. Generated files are ready - Review structure
|
|
379
|
-
ls -la modules/your-feature/
|
|
380
|
-
|
|
381
|
-
# ✅ 2. Add business properties to entities
|
|
382
|
-
# Edit: application/domain/entities/[entity].entity.ts
|
|
383
|
-
# Add: name: string; email: string; etc.
|
|
277
|
+
All generated APIs follow RESTful conventions with security:
|
|
384
278
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
279
|
+
| Method | Path | Description |
|
|
280
|
+
|--------|------|-------------|
|
|
281
|
+
| GET | `/entities` | List with pagination |
|
|
282
|
+
| GET | `/entities/:id` | Get single entity |
|
|
283
|
+
| POST | `/entities` | Create new entity |
|
|
284
|
+
| PUT | `/entities/:id` | Update entity |
|
|
285
|
+
| DELETE | `/entities/:id` | Soft delete entity |
|
|
388
286
|
|
|
389
|
-
|
|
390
|
-
# Edit: infrastructure/orm-entities/[entity].orm-entity.ts
|
|
391
|
-
# Add: @Column() name: string; @Column() email: string;
|
|
287
|
+
### Pagination
|
|
392
288
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
# Add: YourFeatureModule to imports array
|
|
289
|
+
```
|
|
290
|
+
GET /entities?page=1&limit=10&sortBy=createdAt&sortOrder=DESC
|
|
396
291
|
```
|
|
397
292
|
|
|
398
|
-
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
export class GetMonthlyRevenueHandler {
|
|
410
|
-
async execute(query: GetMonthlyRevenueQuery) {
|
|
411
|
-
// Complex business queries - not CRUD
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// ✅ Handle domain events for integration
|
|
416
|
-
@EventsHandler(OrderCreatedEvent)
|
|
417
|
-
export class OrderCreatedHandler {
|
|
418
|
-
async handle(event: OrderCreatedEvent) {
|
|
419
|
-
// Send emails, update analytics, etc.
|
|
293
|
+
Response:
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"items": [...],
|
|
297
|
+
"meta": {
|
|
298
|
+
"total": 100,
|
|
299
|
+
"page": 1,
|
|
300
|
+
"limit": 10,
|
|
301
|
+
"totalPages": 10,
|
|
302
|
+
"hasNextPage": true,
|
|
303
|
+
"hasPreviousPage": false
|
|
420
304
|
}
|
|
421
305
|
}
|
|
422
306
|
```
|
|
423
307
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
## Why This CLI Exists
|
|
308
|
+
## Philosophy
|
|
427
309
|
|
|
428
|
-
###
|
|
429
|
-
-
|
|
430
|
-
-
|
|
431
|
-
-
|
|
432
|
-
- Mixed patterns in the same codebase
|
|
433
|
-
- New developers spending weeks learning "our way"
|
|
310
|
+
### Security First
|
|
311
|
+
- OWASP Top 10 compliance built-in
|
|
312
|
+
- Secure defaults, not optional add-ons
|
|
313
|
+
- Production-ready from day one
|
|
434
314
|
|
|
435
|
-
###
|
|
436
|
-
-
|
|
437
|
-
-
|
|
438
|
-
-
|
|
439
|
-
- **Instant onboarding** - same structure everywhere
|
|
440
|
-
- **Focus on business logic** instead of architecture decisions
|
|
315
|
+
### Immutable Architecture
|
|
316
|
+
- Each generated component remains unchanged after creation
|
|
317
|
+
- New requirements create new use cases, never modify existing ones
|
|
318
|
+
- Predictable structure enables instant developer onboarding
|
|
441
319
|
|
|
442
|
-
###
|
|
443
|
-
-
|
|
444
|
-
- Consistent
|
|
445
|
-
-
|
|
446
|
-
- New developers productive from day one
|
|
447
|
-
- No more "where does this file go?" questions
|
|
320
|
+
### Opinionated by Design
|
|
321
|
+
- Zero configuration fatigue - one way to do things
|
|
322
|
+
- Consistent naming across all projects
|
|
323
|
+
- Battle-tested patterns from enterprise applications
|
|
448
324
|
|
|
449
|
-
|
|
325
|
+
### CQRS Compliance
|
|
326
|
+
- Commands for writes, queries for reads
|
|
327
|
+
- Clear separation of concerns
|
|
328
|
+
- Testable by default
|
|
450
329
|
|
|
451
|
-
## Contributing
|
|
452
|
-
|
|
453
|
-
### 🔧 **Local Development**
|
|
330
|
+
## Contributing
|
|
454
331
|
|
|
455
332
|
```bash
|
|
456
|
-
# Clone and setup
|
|
457
333
|
git clone https://github.com/eshe-huli/nestjs-ddd-cli
|
|
458
334
|
cd nestjs-ddd-cli
|
|
459
335
|
npm install
|
|
460
|
-
|
|
461
|
-
# Test changes locally
|
|
462
|
-
npm run dev -- generate entity Test -m test
|
|
463
|
-
|
|
464
|
-
# Build for production
|
|
465
336
|
npm run build
|
|
337
|
+
npm link
|
|
466
338
|
|
|
467
|
-
# Test
|
|
468
|
-
ddd
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
### 🧪 **Testing Your Changes**
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
# Create a test project
|
|
475
|
-
mkdir test-project && cd test-project
|
|
476
|
-
|
|
477
|
-
# Test scaffolding
|
|
478
|
-
ddd scaffold Product -m inventory
|
|
479
|
-
|
|
480
|
-
# Verify structure matches expectations
|
|
481
|
-
tree modules/inventory/
|
|
482
|
-
|
|
483
|
-
# Test individual generators
|
|
484
|
-
ddd generate service ProductValidator -m inventory
|
|
485
|
-
ddd generate event ProductCreated -m inventory
|
|
486
|
-
ddd generate query GetProductsByCategory -m inventory
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
### 📋 **Template Structure**
|
|
339
|
+
# Test locally
|
|
340
|
+
ddd scaffold Test -m test-module --fields "name:string"
|
|
490
341
|
```
|
|
491
|
-
src/templates/
|
|
492
|
-
├── 📁 entity/ # Domain entity templates
|
|
493
|
-
├── 📁 service/ # Domain service templates
|
|
494
|
-
├── 📁 event/ # Domain event templates
|
|
495
|
-
├── 📁 query/ # Query handler templates
|
|
496
|
-
├── 📁 usecase/ # Use case templates
|
|
497
|
-
├── 📁 controller/ # Controller templates
|
|
498
|
-
├── 📁 repository/ # Repository templates
|
|
499
|
-
└── 📁 ... (more templates)
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
> **🤝 Pull requests welcome!** Help make DDD development even better.
|
|
503
342
|
|
|
504
343
|
## License
|
|
505
344
|
|
|
506
|
-
MIT
|
|
345
|
+
MIT
|