nestforge-generator 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +39 -23
  2. package/README.pt-BR.md +39 -23
  3. package/dist/features/database.js +35 -0
  4. package/dist/features/database.js.map +1 -1
  5. package/dist/features/language.js +19 -1
  6. package/dist/features/language.js.map +1 -1
  7. package/dist/features/no-orm.js +493 -0
  8. package/dist/features/no-orm.js.map +1 -0
  9. package/dist/generator.js +27 -7
  10. package/dist/generator.js.map +1 -1
  11. package/dist/index.js +24 -13
  12. package/dist/index.js.map +1 -1
  13. package/dist/prompts.js +32 -22
  14. package/dist/prompts.js.map +1 -1
  15. package/package.json +2 -1
  16. package/templates/drizzle/README.md +2 -0
  17. package/templates/drizzle/README.pt-BR.md +2 -0
  18. package/templates/prisma/.github/workflows/ci.yml +24 -1
  19. package/templates/prisma/ARCHITECTURE.md +7 -1
  20. package/templates/prisma/ARCHITECTURE.pt-BR.md +7 -1
  21. package/templates/prisma/README.md +11 -7
  22. package/templates/prisma/README.pt-BR.md +11 -7
  23. package/templates/prisma/ROADMAP.md +5 -1
  24. package/templates/prisma/ROADMAP.pt-BR.md +5 -1
  25. package/templates/prisma/TESTING.md +25 -3
  26. package/templates/prisma/TESTING.pt-BR.md +25 -3
  27. package/templates/prisma/docker-compose.yml +29 -1
  28. package/templates/prisma/docs/adding-a-module.md +246 -230
  29. package/templates/prisma/docs/features-markers.md +11 -1
  30. package/templates/prisma/prisma/schema.prisma +4 -0
  31. package/templates/prisma/src/auth/token.service.ts +12 -3
  32. package/templates/prisma/src/health/indicators/prisma-health.indicator.spec.ts +39 -22
  33. package/templates/prisma/src/health/indicators/prisma-health.indicator.ts +24 -19
  34. package/templates/typeorm/README.md +2 -0
  35. package/templates/typeorm/README.pt-BR.md +2 -0
package/dist/prompts.js CHANGED
@@ -55,16 +55,22 @@ export async function runPrompts() {
55
55
  });
56
56
  handleCancel(orm);
57
57
  // 4. Database
58
- const database = await select({
59
- message: 'Which database do you want to use?',
60
- options: [
61
- { value: 'postgres', label: 'PostgreSQL', hint: 'Recommended' },
62
- { value: 'mysql', label: 'MySQL' },
63
- { value: 'sqlite', label: 'SQLite' },
64
- { value: 'mongodb', label: 'MongoDB', hint: 'coming soon' },
65
- ],
66
- });
67
- handleCancel(database);
58
+ let database = 'none';
59
+ if (orm !== 'none') {
60
+ const databaseSelection = await select({
61
+ message: 'Which database do you want to use?',
62
+ options: [
63
+ { value: 'postgres', label: 'PostgreSQL', hint: 'Recommended' },
64
+ { value: 'mysql', label: 'MySQL' },
65
+ { value: 'sqlite', label: 'SQLite' },
66
+ ...(orm === 'prisma'
67
+ ? [{ value: 'mongodb', label: 'MongoDB' }]
68
+ : []),
69
+ ],
70
+ });
71
+ handleCancel(databaseSelection);
72
+ database = databaseSelection;
73
+ }
68
74
  // 5. Additional features (one yes/no prompt at a time)
69
75
  const features = [];
70
76
  const wantsDocker = await confirm({
@@ -96,16 +102,20 @@ export async function runPrompts() {
96
102
  if (wantsRedis)
97
103
  features.push('redis');
98
104
  // 6. Authentication strategy
99
- const authStrategy = await select({
100
- message: 'Which authentication strategy do you want to use?',
101
- options: [
102
- { value: 'jwt', label: 'JWT', hint: 'Recommended includes Google/GitHub OAuth' },
103
- { value: 'session', label: 'Session/Cookies', hint: 'persistent database-backed session' },
104
- { value: 'oauth', label: 'OAuth (Google/GitHub) only', hint: 'no password login' },
105
- { value: 'none', label: 'None' },
106
- ],
107
- });
108
- handleCancel(authStrategy);
105
+ let authStrategy = 'none';
106
+ if (orm !== 'none') {
107
+ const authStrategySelection = await select({
108
+ message: 'Which authentication strategy do you want to use?',
109
+ options: [
110
+ { value: 'jwt', label: 'JWT', hint: 'Recommended includes Google/GitHub OAuth' },
111
+ { value: 'session', label: 'Session/Cookies', hint: 'persistent database-backed session' },
112
+ { value: 'oauth', label: 'OAuth (Google/GitHub) only', hint: 'no password login' },
113
+ { value: 'none', label: 'None' },
114
+ ],
115
+ });
116
+ handleCancel(authStrategySelection);
117
+ authStrategy = authStrategySelection;
118
+ }
109
119
  // 7. Access control (only applicable when authentication is enabled)
110
120
  let accessControl = false;
111
121
  if (authStrategy !== 'none') {
@@ -127,9 +137,9 @@ export async function runPrompts() {
127
137
  projectName: projectName,
128
138
  language: language,
129
139
  orm: orm,
130
- database: database,
140
+ database,
131
141
  features,
132
- authStrategy: authStrategy,
142
+ authStrategy,
133
143
  accessControl,
134
144
  createEnv: createEnv,
135
145
  };
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,YAAY,CAAC;AAkB5B,mCAAmC;AACnC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAE3D,MAAM,IAAI,GAAG;;;;;;;;;CASZ,CAAC;AAEF,SAAS,UAAU;IACf,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAChC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,MAAM,CAAC,sBAAsB,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU;IAC5B,UAAU,EAAE,CAAC;IACb,KAAK,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EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,oCAAoC,EAAE;gBAC1F,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,4BAA4B,EAAE,IAAI,EAAE,mBAAmB,EAAE;gBAClF,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;aACnC;SACJ,CAAC,CAAC;QACH,YAAY,CAAC,qBAAqB,CAAC,CAAC;QACpC,YAAY,GAAG,qBAA2C,CAAC;IAC/D,CAAC;IAED,qEAAqE;IACrE,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,YAAY,KAAK,MAAM,EAAE,CAAC;QAC1B,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC;YACrC,OAAO,EAAE,kEAAkE;YAC3E,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;QACH,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACjC,aAAa,GAAG,kBAA6B,CAAC;IAClD,CAAC;IAED,6BAA6B;IAC7B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;QAC5B,OAAO,EAAE,wEAAwE;QACjF,YAAY,EAAE,IAAI;KACrB,CAAC,CAAC;IACH,YAAY,CAAC,SAAS,CAAC,CAAC;IAExB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAEtD,OAAO;QACH,WAAW,EAAE,WAAqB;QAClC,QAAQ,EAAE,QAA0B;QACpC,GAAG,EAAE,GAAgB;QACrB,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,aAAa;QACb,SAAS,EAAE,SAAoB;KAClC,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestforge-generator",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Interactive CLI for generating a NestJS project from a NestForge starter template",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -40,6 +40,7 @@
40
40
  "postgresql",
41
41
  "mysql",
42
42
  "sqlite",
43
+ "mongodb",
43
44
  "docker",
44
45
  "swagger",
45
46
  "api",
@@ -25,6 +25,8 @@ NestForge is a NestJS starter designed to accelerate the beginning of serious ba
25
25
  - 🐳 **Docker** — complete environment with a single command
26
26
  - ⚙️ **CI/CD** — GitHub Actions (build, lint, test)
27
27
 
28
+ > **MongoDB compatibility:** MongoDB is not available in this template because Drizzle does not currently provide an official MongoDB dialect. MongoDB generation is currently available through the Prisma template.
29
+
28
30
  ## 🧱 Stack
29
31
 
30
32
  | Layer | Technology |
@@ -25,6 +25,8 @@ NestForge é um boilerplate de NestJS pensado para acelerar o início de projeto
25
25
  - 🐳 **Docker** — ambiente completo com um comando
26
26
  - ⚙️ **CI/CD** — GitHub Actions (build, lint, test)
27
27
 
28
+ > **Compatibilidade com MongoDB:** o MongoDB não está disponível neste template porque o Drizzle não oferece atualmente um dialeto oficial para MongoDB. A geração com MongoDB está disponível atualmente por meio do template Prisma.
29
+
28
30
  ## 🧱 Stack
29
31
 
30
32
  | Camada | Tecnologia |
@@ -64,6 +64,9 @@ jobs:
64
64
  # nestforge:feature:database:sqlite
65
65
  DATABASE_URL: file:./ci-dev.db
66
66
  # nestforge:feature:database:sqlite:end
67
+ # nestforge:feature:database:mongodb
68
+ DATABASE_URL: mongodb://localhost:27017/nestforge?replicaSet=rs0
69
+ # nestforge:feature:database:mongodb:end
67
70
  JWT_ACCESS_SECRET: ci-access-secret-0123456789
68
71
  JWT_REFRESH_SECRET: ci-refresh-secret-0123456789
69
72
 
@@ -77,14 +80,34 @@ jobs:
77
80
  node-version: 20
78
81
  cache: npm
79
82
 
83
+ # nestforge:feature:database:mongodb
84
+ - name: Start MongoDB replica set
85
+ run: |
86
+ docker run --detach --name nestforge-mongodb --publish 27017:27017 mongo:8 mongod --replSet rs0 --bind_ip_all
87
+ for attempt in {1..30}; do
88
+ if docker exec nestforge-mongodb mongosh --quiet --eval "try { rs.status().ok } catch (error) { rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'localhost:27017'}]}).ok }" | grep -q 1; then
89
+ exit 0
90
+ fi
91
+ sleep 2
92
+ done
93
+ exit 1
94
+ # nestforge:feature:database:mongodb:end
95
+
80
96
  - name: Instalar dependências
81
97
  run: npm ci
82
98
 
83
99
  - name: Gerar Prisma Client
84
100
  run: npx prisma generate
85
101
 
102
+ # nestforge:feature:database:relational
86
103
  - name: Rodar migrations
87
104
  run: npx prisma migrate deploy
105
+ # nestforge:feature:database:relational:end
106
+
107
+ # nestforge:feature:database:mongodb
108
+ - name: Sincronizar schema do MongoDB
109
+ run: npx prisma db push
110
+ # nestforge:feature:database:mongodb:end
88
111
 
89
112
  - name: Lint
90
113
  run: npm run lint
@@ -106,4 +129,4 @@ jobs:
106
129
  # nestforge:feature:database:mysql:end
107
130
 
108
131
  - name: Testes e2e
109
- run: npm run test:e2e
132
+ run: npm run test:e2e
@@ -11,7 +11,7 @@ Request → main.ts (global pipes/filters/interceptors)
11
11
  → Guards (JwtAuthGuard → RolesGuard → PermissionsGuard)
12
12
  → Controller (validates through a Zod DTO, delegates to the service)
13
13
  → Service (business rules, calls Prisma)
14
- → Prisma → PostgreSQL
14
+ → Prisma → selected database
15
15
  → Response (passes through ClassSerializerInterceptor before becoming JSON)
16
16
  ```
17
17
 
@@ -38,6 +38,12 @@ Controllers never communicate with Prisma directly — they always go through th
38
38
 
39
39
  Prisma Client is effectively already a type-safe repository. Adding an abstraction layer on top merely to “follow the pattern” would add indirection without a real benefit in this project (there is no plan to replace the ORM). Services call `this.prisma.<model>` directly.
40
40
 
41
+ ### How does MongoDB differ from the relational databases?
42
+
43
+ MongoDB documents use `_id`. The generated Prisma schema maps model IDs to `_id`, uses native `ObjectId` values where IDs are generated by MongoDB, and marks relation scalar fields with `@db.ObjectId`. The session store keeps its externally supplied string ID mapped directly to `_id`.
44
+
45
+ MongoDB uses `prisma db push` instead of Prisma Migrate. A replica set is required for transactional and nested-write behavior, so the generated Docker Compose starts a single-node replica set. The database health indicator uses MongoDB's `ping` command instead of executing `SELECT 1`.
46
+
41
47
  ### Why are permissions a fixed map in code (`ROLE_PERMISSIONS`) instead of a database table?
42
48
 
43
49
  A fully dynamic permission system (`roles`, `permissions`, and `role_permissions` tables) is overkill for a starter — most projects created from it will have 3–5 fixed roles. Keeping the mapping in `src/common/constants/role-permissions.ts` makes it explicitly auditable: the entire permission array for every role is visible in one file. If the project grows enough to require permissions configurable at runtime (for example, an administrator creating custom roles through the UI), then migrating to database tables becomes worthwhile.
@@ -11,7 +11,7 @@ Request → main.ts (pipes/filters/interceptors globais)
11
11
  → Guards (JwtAuthGuard → RolesGuard → PermissionsGuard)
12
12
  → Controller (valida via DTO Zod, delega pro service)
13
13
  → Service (regra de negócio, chama o Prisma)
14
- → Prisma → PostgreSQL
14
+ → Prisma → banco selecionado
15
15
  → Response (passa pelo ClassSerializerInterceptor antes de virar JSON)
16
16
  ```
17
17
 
@@ -36,6 +36,12 @@ Controllers nunca falam com o Prisma diretamente — sempre passam pelo service.
36
36
  ### Por que Prisma sem uma camada de "repository" por cima?
37
37
  Prisma Client já é, na prática, um repository type-safe — adicionar uma camada de abstração em cima dele só pra "seguir o padrão" adicionaria indireção sem trazer benefício real neste projeto (não há plano de trocar de ORM). Os services chamam `this.prisma.<model>` diretamente.
38
38
 
39
+ ### Como o MongoDB difere dos bancos relacionais?
40
+
41
+ Documentos MongoDB usam `_id`. O schema Prisma gerado mapeia os IDs dos models para `_id`, usa valores nativos `ObjectId` quando os IDs são gerados pelo MongoDB e marca os campos escalares de relação com `@db.ObjectId`. O armazenamento de sessão mantém seu ID textual fornecido externamente mapeado diretamente para `_id`.
42
+
43
+ MongoDB usa `prisma db push` no lugar do Prisma Migrate. Um replica set é necessário para transações e escritas aninhadas, então o Docker Compose gerado inicia um replica set de nó único. O indicador de saúde usa o comando `ping` do MongoDB em vez de executar `SELECT 1`.
44
+
39
45
  ### Por que permissions são um mapa fixo em código (`ROLE_PERMISSIONS`) e não uma tabela no banco?
40
46
  Um sistema de permissions 100% dinâmico (tabelas `roles`, `permissions`, `role_permissions`) é overkill pra um boilerplate — a maioria dos projetos que nascem daqui vai ter 3-5 roles fixas. Manter o mapeamento em `src/common/constants/role-permissions.ts` deixa auditável de forma explícita: dá pra ver o array inteiro de permissões de cada role em um arquivo só. Se o seu projeto crescer a ponto de precisar de permissions configuráveis em runtime (ex.: um admin criando roles customizadas pela UI), aí sim vale migrar pra tabela.
41
47
 
@@ -17,7 +17,7 @@ NestForge is a NestJS starter designed to accelerate the beginning of serious ba
17
17
  - 🌐 **OAuth** — Google and GitHub, integrated with the selected token or session strategy
18
18
  - 👥 **RBAC** — Roles (Admin, Manager, User) and granular Permissions
19
19
  - 🛡️ **Security** — Helmet, CORS, Rate Limiting, validation, and serialization with Zod
20
- - 🗄️ **Database** — Prisma with PostgreSQL, MySQL, or SQLite
20
+ - 🗄️ **Database** — Prisma with PostgreSQL, MySQL, SQLite, or MongoDB
21
21
  - 📨 **Email** — queues with BullMQ + Redis, locally tested with Mailpit
22
22
  - 📄 **Automatic documentation** — Swagger
23
23
  - 🪵 **Structured logs** — Pino
@@ -31,7 +31,7 @@ NestForge is a NestJS starter designed to accelerate the beginning of serious ba
31
31
  |---|---|
32
32
  | Framework | NestJS + TypeScript |
33
33
  | ORM | Prisma |
34
- | Database | PostgreSQL, MySQL, or SQLite |
34
+ | Database | PostgreSQL, MySQL, SQLite, or MongoDB |
35
35
  | Cache / Queues | Redis + BullMQ |
36
36
  | Authentication | JWT, Session/Cookies, or OAuth with Passport |
37
37
  | Validation | Zod + nestjs-zod (schemas automatically become DTOs + Swagger) |
@@ -73,14 +73,19 @@ cp .env.example .env
73
73
  docker compose up
74
74
  ```
75
75
 
76
- This starts the API, PostgreSQL, Redis, and Mailpit (email interface at `http://localhost:8025`).
76
+ This starts the API, the selected database, Redis, and Mailpit (email interface at `http://localhost:8025`). MongoDB runs as a single-node replica set for transaction support.
77
77
 
78
78
  ### Running locally
79
79
 
80
80
  ```bash
81
81
  npm install
82
82
  cp .env.example .env
83
+ # nestforge:feature:database:relational
83
84
  npx prisma migrate dev
85
+ # nestforge:feature:database:relational:end
86
+ # nestforge:feature:database:mongodb
87
+ npm run prisma:push
88
+ # nestforge:feature:database:mongodb:end
84
89
  npx prisma db seed
85
90
  npm run start:dev
86
91
  ```
@@ -234,15 +239,14 @@ npm run test:e2e # integration tests (E2E)
234
239
  npm run test:cov # coverage
235
240
  ```
236
241
 
237
- E2E tests (`test/*.e2e-spec.ts`) start the real application (Nest + Prisma + Redis) and call its endpoints with `supertest`, using an isolated database (`.env.test`, the `nestforge_test` database — never the development database). Before running them for the first time:
242
+ E2E tests (`test/*.e2e-spec.ts`) start the real application (Nest + Prisma + Redis) and call its endpoints with `supertest`, using an isolated database (`.env.test`, the `nestforge_test` database — never the development database). Before running them for the first time, start the selected database and Redis:
238
243
 
239
244
  ```bash
240
- createdb nestforge_test # or: psql -U nestforge -c "CREATE DATABASE nestforge_test;"
241
- docker compose up -d postgres redis
245
+ docker compose up -d
242
246
  npm run test:e2e
243
247
  ```
244
248
 
245
- The `pretest:e2e` script automatically applies migrations to this database before every run. Each test cleans the tables before running (`test/utils/clean-database.ts`), so nothing needs to be reset manually between runs. Current coverage includes the complete authentication flow (registration, login, refresh, logout, duplicate email, invalid credentials) and user CRUD with RBAC (ADMIN can do everything, USER can read but cannot create, `/users/me`, and access without a token).
249
+ The `pretest:e2e` script automatically applies migrations for relational databases or pushes the Prisma schema for MongoDB before every run. Each test cleans the database before running (`test/utils/clean-database.ts`), so nothing needs to be reset manually between runs. Current coverage includes the complete authentication flow (registration, login, refresh, logout, duplicate email, invalid credentials) and user CRUD with RBAC (ADMIN can do everything, USER can read but cannot create, `/users/me`, and access without a token).
246
250
 
247
251
  Unit tests (`src/**/*.spec.ts`) run in isolation with Prisma and `ioredis` mocked (`vi.fn()` / `vi.mock()`), so they do not require a real database or Redis. Current coverage includes `AuthService` (registration/login), `UsersService` (complete CRUD + pagination + confirmation through `instanceToPlain` that `passwordHash` is not leaked during serialization), `RolesGuard` and `PermissionsGuard` (allowing/blocking, including multiple permissions required at the same time), and health indicators (`PrismaHealthIndicator`, `RedisHealthIndicator`).
248
252
 
@@ -17,7 +17,7 @@ NestForge é um boilerplate de NestJS pensado para acelerar o início de projeto
17
17
  - 🌐 **OAuth** — Google e GitHub, integrado à estratégia de token ou sessão escolhida
18
18
  - 👥 **RBAC** — Roles (Admin, Manager, User) e Permissions granulares
19
19
  - 🛡️ **Segurança** — Helmet, CORS, Rate Limiting, validação e serialização com Zod
20
- - 🗄️ **Banco de dados** — Prisma com PostgreSQL, MySQL ou SQLite
20
+ - 🗄️ **Banco de dados** — Prisma com PostgreSQL, MySQL, SQLite ou MongoDB
21
21
  - 📨 **E-mails** — filas com BullMQ + Redis, testado localmente com Mailpit
22
22
  - 📄 **Documentação automática** — Swagger
23
23
  - 🪵 **Logs estruturados** — Pino
@@ -31,7 +31,7 @@ NestForge é um boilerplate de NestJS pensado para acelerar o início de projeto
31
31
  |---|---|
32
32
  | Framework | NestJS + TypeScript |
33
33
  | ORM | Prisma |
34
- | Banco | PostgreSQL, MySQL ou SQLite |
34
+ | Banco | PostgreSQL, MySQL, SQLite ou MongoDB |
35
35
  | Cache / Filas | Redis + BullMQ |
36
36
  | Autenticação | JWT, Session/Cookies ou OAuth com Passport |
37
37
  | Validação | Zod + nestjs-zod (schemas viram DTO + Swagger automaticamente) |
@@ -73,14 +73,19 @@ cp .env.example .env
73
73
  docker compose up
74
74
  ```
75
75
 
76
- Isso sobe: API, PostgreSQL, Redis e Mailpit (interface de e-mail em `http://localhost:8025`).
76
+ Isso sobe a API, o banco selecionado, Redis e Mailpit (interface de e-mail em `http://localhost:8025`). O MongoDB funciona como replica set de nó único para permitir transações.
77
77
 
78
78
  ### Rodando localmente
79
79
 
80
80
  ```bash
81
81
  npm install
82
82
  cp .env.example .env
83
+ # nestforge:feature:database:relational
83
84
  npx prisma migrate dev
85
+ # nestforge:feature:database:relational:end
86
+ # nestforge:feature:database:mongodb
87
+ npm run prisma:push
88
+ # nestforge:feature:database:mongodb:end
84
89
  npx prisma db seed
85
90
  npm run start:dev
86
91
  ```
@@ -234,15 +239,14 @@ npm run test:e2e # integração (e2e)
234
239
  npm run test:cov # cobertura
235
240
  ```
236
241
 
237
- Os testes e2e (`test/*.e2e-spec.ts`) sobem a aplicação real (Nest + Prisma + Redis) e batem nos endpoints com `supertest`, usando um banco isolado (`.env.test`, banco `nestforge_test` — nunca o de desenvolvimento). Antes de rodar pela primeira vez:
242
+ Os testes e2e (`test/*.e2e-spec.ts`) sobem a aplicação real (Nest + Prisma + Redis) e batem nos endpoints com `supertest`, usando um banco isolado (`.env.test`, banco `nestforge_test` — nunca o de desenvolvimento). Antes de rodar pela primeira vez, inicie o banco selecionado e o Redis:
238
243
 
239
244
  ```bash
240
- createdb nestforge_test # ou: psql -U nestforge -c "CREATE DATABASE nestforge_test;"
241
- docker compose up -d postgres redis
245
+ docker compose up -d
242
246
  npm run test:e2e
243
247
  ```
244
248
 
245
- O script `pretest:e2e` aplica as migrations nesse banco automaticamente antes de cada rodada. Cada teste limpa as tabelas antes de rodar (`test/utils/clean-database.ts`), então não precisa zerar nada manualmente entre execuções. Hoje cobrem o fluxo de autenticação completo (registro, login, refresh, logout, e-mail duplicado, credenciais inválidas) e o CRUD de usuários com RBAC (ADMIN consegue tudo, USER lê mas não cria, `/users/me`, acesso sem token).
249
+ O script `pretest:e2e` aplica as migrations nos bancos relacionais ou envia o schema Prisma ao MongoDB antes de cada rodada. Cada teste limpa o banco antes de rodar (`test/utils/clean-database.ts`), então não precisa zerar nada manualmente entre execuções. Hoje cobrem o fluxo de autenticação completo (registro, login, refresh, logout, e-mail duplicado, credenciais inválidas) e o CRUD de usuários com RBAC (ADMIN consegue tudo, USER lê mas não cria, `/users/me`, acesso sem token).
246
250
 
247
251
  Os testes unitários (`src/**/*.spec.ts`) rodam isolados, com Prisma e `ioredis` mockados (`vi.fn()` / `vi.mock()`) — não precisam de banco nem Redis de verdade. Hoje cobrem: `AuthService` (registro/login), `UsersService` (CRUD completo + paginação + confirma que o `passwordHash` não vaza na serialização via `instanceToPlain`), `RolesGuard` e `PermissionsGuard` (liberação/bloqueio, inclusive com múltiplas permissões exigidas ao mesmo tempo) e os indicadores de saúde (`PrismaHealthIndicator`, `RedisHealthIndicator`).
248
252
 
@@ -41,7 +41,11 @@ This roadmap makes it clear what is ready and where contributions are possible.
41
41
 
42
42
  - [x] Prisma
43
43
  - [x] PostgreSQL
44
- - [x] Migrations
44
+ - [x] MySQL
45
+ - [x] SQLite
46
+ - [x] MongoDB
47
+ - [x] Migrations for relational databases
48
+ - [x] Schema synchronization with `prisma db push` for MongoDB
45
49
  - [x] Complete seed (roles, permissions, administrator user)
46
50
 
47
51
  ## Infrastructure
@@ -36,7 +36,11 @@ Este roadmap existe para deixar claro o que já está pronto e onde dá pra cont
36
36
  ## Banco de dados
37
37
  - [x] Prisma
38
38
  - [x] PostgreSQL
39
- - [x] Migrations
39
+ - [x] MySQL
40
+ - [x] SQLite
41
+ - [x] MongoDB
42
+ - [x] Migrations para bancos relacionais
43
+ - [x] Sincronização do schema com `prisma db push` para MongoDB
40
44
  - [x] Seed completo (roles, permissions, usuário admin)
41
45
 
42
46
  ## Infra
@@ -8,7 +8,7 @@ This guide validates a project generated from the NestForge Prisma template.
8
8
 
9
9
  * Node.js 20 or later
10
10
  * npm 10 or later
11
- * Docker when testing PostgreSQL, MySQL, Redis, or Mailpit
11
+ * Docker when testing PostgreSQL, MySQL, MongoDB, Redis, or Mailpit
12
12
 
13
13
  SQLite can be tested without Docker.
14
14
 
@@ -30,10 +30,18 @@ npm run prisma:generate
30
30
 
31
31
  ## Apply the development schema
32
32
 
33
+ For PostgreSQL, MySQL, or SQLite:
34
+
33
35
  ```bash
34
36
  npm run prisma:migrate -- --name init
35
37
  ```
36
38
 
39
+ For MongoDB:
40
+
41
+ ```bash
42
+ npm run prisma:push
43
+ ```
44
+
37
45
  Run the seed when the generated project includes password authentication:
38
46
 
39
47
  ```bash
@@ -67,7 +75,7 @@ Unit tests mock Prisma and Redis, so they do not require real services.
67
75
  npm run test:e2e
68
76
  ```
69
77
 
70
- The `pretest:e2e` script runs `prisma migrate deploy` with `.env.test` before the suite starts.
78
+ The `pretest:e2e` script runs `prisma migrate deploy` for relational databases or `prisma db push` for MongoDB with `.env.test` before the suite starts.
71
79
 
72
80
  Depending on the generated authentication strategy, the suite may cover:
73
81
 
@@ -110,11 +118,25 @@ npm test
110
118
  npm run test:e2e
111
119
  ```
112
120
 
121
+ ### MongoDB
122
+
123
+ MongoDB must run as a replica set because Prisma uses transactions for nested writes. The generated Docker Compose configures a single-node replica set:
124
+
125
+ ```bash
126
+ docker compose up -d mongodb
127
+ npm run prisma:push
128
+ npm run build
129
+ npm test
130
+ npm run test:e2e
131
+ ```
132
+
133
+ Use different database names in `.env` and `.env.test`, such as `nestforge` and `nestforge_test`.
134
+
113
135
  ## Final checklist
114
136
 
115
137
  * [ ] Dependencies install successfully
116
138
  * [ ] Prisma Client is generated
117
- * [ ] Migrations are applied
139
+ * [ ] Migrations are applied, or the MongoDB schema is pushed
118
140
  * [ ] Seed runs when applicable
119
141
  * [ ] Build passes
120
142
  * [ ] Lint passes
@@ -8,7 +8,7 @@ Este guia valida um projeto gerado a partir do template Prisma do NestForge.
8
8
 
9
9
  * Node.js 20 ou superior
10
10
  * npm 10 ou superior
11
- * Docker para testar PostgreSQL, MySQL, Redis ou Mailpit
11
+ * Docker para testar PostgreSQL, MySQL, MongoDB, Redis ou Mailpit
12
12
 
13
13
  SQLite pode ser testado sem Docker.
14
14
 
@@ -30,10 +30,18 @@ npm run prisma:generate
30
30
 
31
31
  ## Aplicar o schema de desenvolvimento
32
32
 
33
+ Para PostgreSQL, MySQL ou SQLite:
34
+
33
35
  ```bash
34
36
  npm run prisma:migrate -- --name init
35
37
  ```
36
38
 
39
+ Para MongoDB:
40
+
41
+ ```bash
42
+ npm run prisma:push
43
+ ```
44
+
37
45
  Execute o seed quando o projeto gerado incluir autenticação por senha:
38
46
 
39
47
  ```bash
@@ -67,7 +75,7 @@ Os testes unitários simulam Prisma e Redis, portanto não exigem serviços reai
67
75
  npm run test:e2e
68
76
  ```
69
77
 
70
- O script `pretest:e2e` executa `prisma migrate deploy` com `.env.test` antes do início da suíte.
78
+ O script `pretest:e2e` executa `prisma migrate deploy` nos bancos relacionais ou `prisma db push` no MongoDB com `.env.test` antes do início da suíte.
71
79
 
72
80
  Dependendo da estratégia de autenticação gerada, a suíte pode cobrir:
73
81
 
@@ -110,11 +118,25 @@ npm test
110
118
  npm run test:e2e
111
119
  ```
112
120
 
121
+ ### MongoDB
122
+
123
+ O MongoDB deve funcionar como replica set porque o Prisma usa transações em escritas aninhadas. O Docker Compose gerado configura um replica set de nó único:
124
+
125
+ ```bash
126
+ docker compose up -d mongodb
127
+ npm run prisma:push
128
+ npm run build
129
+ npm test
130
+ npm run test:e2e
131
+ ```
132
+
133
+ Use nomes de banco diferentes em `.env` e `.env.test`, como `nestforge` e `nestforge_test`.
134
+
113
135
  ## Checklist final
114
136
 
115
137
  * [ ] As dependências são instaladas corretamente
116
138
  * [ ] O Prisma Client é gerado
117
- * [ ] As migrations são aplicadas
139
+ * [ ] As migrations são aplicadas ou o schema MongoDB é enviado
118
140
  * [ ] O seed executa quando aplicável
119
141
  * [ ] O build passa
120
142
  * [ ] O lint passa
@@ -10,6 +10,10 @@ services:
10
10
  - "3000:3000"
11
11
  env_file:
12
12
  - .env
13
+ # nestforge:feature:database:mongodb
14
+ environment:
15
+ DATABASE_URL: mongodb://mongodb:27017/nestforge?replicaSet=rs0
16
+ # nestforge:feature:database:mongodb:end
13
17
  depends_on:
14
18
  # nestforge:feature:database:postgres
15
19
  - postgres
@@ -17,6 +21,9 @@ services:
17
21
  # nestforge:feature:database:mysql
18
22
  - mysql
19
23
  # nestforge:feature:database:mysql:end
24
+ # nestforge:feature:database:mongodb
25
+ - mongodb
26
+ # nestforge:feature:database:mongodb:end
20
27
  - redis
21
28
  volumes:
22
29
  - ./src:/app/src
@@ -53,6 +60,23 @@ services:
53
60
  - mysql_data:/var/lib/mysql
54
61
  # nestforge:feature:database:mysql:end
55
62
 
63
+ # nestforge:feature:database:mongodb
64
+ mongodb:
65
+ image: mongo:8
66
+ container_name: nestforge-mongodb
67
+ restart: unless-stopped
68
+ command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
69
+ ports:
70
+ - "27017:27017"
71
+ volumes:
72
+ - mongodb_data:/data/db
73
+ healthcheck:
74
+ test: ["CMD-SHELL", "mongosh --quiet --eval \"try { rs.status().ok } catch (error) { rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'mongodb:27017'}]}).ok }\" | grep 1"]
75
+ interval: 5s
76
+ timeout: 5s
77
+ retries: 10
78
+ # nestforge:feature:database:mongodb:end
79
+
56
80
  redis:
57
81
  image: redis:7-alpine
58
82
  container_name: nestforge-redis
@@ -75,4 +99,8 @@ volumes:
75
99
  # nestforge:feature:database:mysql
76
100
  volumes:
77
101
  mysql_data:
78
- # nestforge:feature:database:mysql:end
102
+ # nestforge:feature:database:mysql:end
103
+ # nestforge:feature:database:mongodb
104
+ volumes:
105
+ mongodb_data:
106
+ # nestforge:feature:database:mongodb:end