nestforge-generator 0.1.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.
- package/LICENSE +21 -0
- package/README.md +371 -0
- package/README.pt-BR.md +370 -0
- package/dist/features/auth-strategy.js +19 -0
- package/dist/features/auth-strategy.js.map +1 -0
- package/dist/features/database.js +59 -0
- package/dist/features/database.js.map +1 -0
- package/dist/features/dependencies.js +57 -0
- package/dist/features/dependencies.js.map +1 -0
- package/dist/features/language.js +172 -0
- package/dist/features/language.js.map +1 -0
- package/dist/features/markers.js +116 -0
- package/dist/features/markers.js.map +1 -0
- package/dist/generator.js +120 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.js +137 -0
- package/dist/prompts.js.map +1 -0
- package/package.json +76 -0
- package/templates/drizzle/.env.example +45 -0
- package/templates/drizzle/.env.test +38 -0
- package/templates/drizzle/.github/workflows/ci.yml +119 -0
- package/templates/drizzle/ARCHITECTURE.md +227 -0
- package/templates/drizzle/ARCHITECTURE.pt-BR.md +225 -0
- package/templates/drizzle/CODE_OF_CONDUCT.md +29 -0
- package/templates/drizzle/CODE_OF_CONDUCT.pt-BR.md +27 -0
- package/templates/drizzle/CONTRIBUTING.md +57 -0
- package/templates/drizzle/CONTRIBUTING.pt-BR.md +54 -0
- package/templates/drizzle/Dockerfile +43 -0
- package/templates/drizzle/LICENSE +21 -0
- package/templates/drizzle/README.md +257 -0
- package/templates/drizzle/README.pt-BR.md +257 -0
- package/templates/drizzle/ROADMAP.md +143 -0
- package/templates/drizzle/ROADMAP.pt-BR.md +143 -0
- package/templates/drizzle/TESTING.md +136 -0
- package/templates/drizzle/TESTING.pt-BR.md +136 -0
- package/templates/drizzle/docker-compose.yml +82 -0
- package/templates/drizzle/docs/adding-a-module.md +585 -0
- package/templates/drizzle/docs/features-markers.md +457 -0
- package/templates/drizzle/drizzle.config.ts +49 -0
- package/templates/drizzle/nest-cli.json +8 -0
- package/templates/drizzle/package.json +96 -0
- package/templates/drizzle/src/app.module.ts +72 -0
- package/templates/drizzle/src/auth/auth.controller.ts +283 -0
- package/templates/drizzle/src/auth/auth.module.ts +81 -0
- package/templates/drizzle/src/auth/auth.service.spec.ts +111 -0
- package/templates/drizzle/src/auth/auth.service.ts +631 -0
- package/templates/drizzle/src/auth/drizzle-session.store.ts +263 -0
- package/templates/drizzle/src/auth/dto/forgot-password.dto.ts +9 -0
- package/templates/drizzle/src/auth/dto/login.dto.ts +10 -0
- package/templates/drizzle/src/auth/dto/refresh-token.dto.ts +9 -0
- package/templates/drizzle/src/auth/dto/register.dto.ts +11 -0
- package/templates/drizzle/src/auth/dto/reset-password.dto.ts +10 -0
- package/templates/drizzle/src/auth/guards/github-auth.guard.ts +10 -0
- package/templates/drizzle/src/auth/guards/google-auth.guard.ts +10 -0
- package/templates/drizzle/src/auth/guards/jwt-auth.guard.ts +25 -0
- package/templates/drizzle/src/auth/guards/session-auth.guard.spec.ts +77 -0
- package/templates/drizzle/src/auth/guards/session-auth.guard.ts +37 -0
- package/templates/drizzle/src/auth/session.service.spec.ts +74 -0
- package/templates/drizzle/src/auth/session.service.ts +96 -0
- package/templates/drizzle/src/auth/strategies/github.strategy.ts +41 -0
- package/templates/drizzle/src/auth/strategies/google.strategy.ts +43 -0
- package/templates/drizzle/src/auth/strategies/jwt.strategy.ts +25 -0
- package/templates/drizzle/src/auth/token.service.ts +175 -0
- package/templates/drizzle/src/common/constants/permissions.ts +8 -0
- package/templates/drizzle/src/common/constants/role-permissions.ts +9 -0
- package/templates/drizzle/src/common/constants/role.enum.ts +5 -0
- package/templates/drizzle/src/common/decorators/current-user.decorator.ts +8 -0
- package/templates/drizzle/src/common/decorators/permissions.decorator.ts +7 -0
- package/templates/drizzle/src/common/decorators/public.decorator.ts +4 -0
- package/templates/drizzle/src/common/decorators/roles.decorator.ts +6 -0
- package/templates/drizzle/src/common/filters/http-exception.filter.ts +34 -0
- package/templates/drizzle/src/common/guards/permissions.guard.spec.ts +54 -0
- package/templates/drizzle/src/common/guards/permissions.guard.ts +28 -0
- package/templates/drizzle/src/common/guards/roles.guard.spec.ts +37 -0
- package/templates/drizzle/src/common/guards/roles.guard.ts +24 -0
- package/templates/drizzle/src/common/interceptors/logging.interceptor.ts +23 -0
- package/templates/drizzle/src/common/middleware/csrf.middleware.spec.ts +97 -0
- package/templates/drizzle/src/common/middleware/csrf.middleware.ts +46 -0
- package/templates/drizzle/src/common/utils/avatar-storage.util.ts +32 -0
- package/templates/drizzle/src/common/utils/hash.util.ts +5 -0
- package/templates/drizzle/src/config/env.validation.ts +50 -0
- package/templates/drizzle/src/database/database-lifecycle.service.ts +30 -0
- package/templates/drizzle/src/database/database.constants.ts +2 -0
- package/templates/drizzle/src/database/database.decorators.ts +5 -0
- package/templates/drizzle/src/database/database.module.ts +96 -0
- package/templates/drizzle/src/database/database.types.ts +28 -0
- package/templates/drizzle/src/database/schema/index.ts +11 -0
- package/templates/drizzle/src/database/schema/mysql.schema.ts +215 -0
- package/templates/drizzle/src/database/schema/postgres.schema.ts +218 -0
- package/templates/drizzle/src/database/schema/sqlite.schema.ts +190 -0
- package/templates/drizzle/src/database/seed.ts +152 -0
- package/templates/drizzle/src/health/health.controller.ts +49 -0
- package/templates/drizzle/src/health/health.module.ts +19 -0
- package/templates/drizzle/src/health/indicators/drizzle-health.indicator.spec.ts +71 -0
- package/templates/drizzle/src/health/indicators/drizzle-health.indicator.ts +52 -0
- package/templates/drizzle/src/health/indicators/redis-health.indicator.spec.ts +54 -0
- package/templates/drizzle/src/health/indicators/redis-health.indicator.ts +33 -0
- package/templates/drizzle/src/mail/mail.module.ts +12 -0
- package/templates/drizzle/src/mail/mail.processor.ts +48 -0
- package/templates/drizzle/src/mail/mail.service.ts +24 -0
- package/templates/drizzle/src/mail/templates/email-templates.ts +28 -0
- package/templates/drizzle/src/main.ts +145 -0
- package/templates/drizzle/src/metrics/metrics.controller.ts +22 -0
- package/templates/drizzle/src/metrics/metrics.interceptor.ts +30 -0
- package/templates/drizzle/src/metrics/metrics.module.ts +12 -0
- package/templates/drizzle/src/metrics/metrics.service.ts +34 -0
- package/templates/drizzle/src/types/express-session.d.ts +13 -0
- package/templates/drizzle/src/users/dto/create-user.dto.ts +12 -0
- package/templates/drizzle/src/users/dto/find-users-query.dto.ts +12 -0
- package/templates/drizzle/src/users/dto/update-user.dto.ts +6 -0
- package/templates/drizzle/src/users/entities/user.entity.ts +23 -0
- package/templates/drizzle/src/users/users.controller.ts +165 -0
- package/templates/drizzle/src/users/users.module.ts +10 -0
- package/templates/drizzle/src/users/users.service.spec.ts +301 -0
- package/templates/drizzle/src/users/users.service.ts +213 -0
- package/templates/drizzle/test/auth.e2e-spec.ts +114 -0
- package/templates/drizzle/test/session-auth.e2e-spec.ts +163 -0
- package/templates/drizzle/test/users.e2e-spec.ts +212 -0
- package/templates/drizzle/test/utils/clean-database.ts +104 -0
- package/templates/drizzle/test/utils/e2e-setup.ts +77 -0
- package/templates/drizzle/tsconfig.build.json +4 -0
- package/templates/drizzle/tsconfig.json +25 -0
- package/templates/drizzle/vitest.config.ts +20 -0
- package/templates/drizzle/vitest.e2e.config.ts +19 -0
- package/templates/prisma/.env.example +44 -0
- package/templates/prisma/.env.test +37 -0
- package/templates/prisma/.github/workflows/ci.yml +109 -0
- package/templates/prisma/ARCHITECTURE.md +70 -0
- package/templates/prisma/ARCHITECTURE.pt-BR.md +63 -0
- package/templates/prisma/CODE_OF_CONDUCT.md +29 -0
- package/templates/prisma/CODE_OF_CONDUCT.pt-BR.md +27 -0
- package/templates/prisma/CONTRIBUTING.md +57 -0
- package/templates/prisma/CONTRIBUTING.pt-BR.md +54 -0
- package/templates/prisma/Dockerfile +33 -0
- package/templates/prisma/LICENSE +21 -0
- package/templates/prisma/README.md +267 -0
- package/templates/prisma/README.pt-BR.md +267 -0
- package/templates/prisma/ROADMAP.md +75 -0
- package/templates/prisma/ROADMAP.pt-BR.md +65 -0
- package/templates/prisma/TESTING.md +123 -0
- package/templates/prisma/TESTING.pt-BR.md +123 -0
- package/templates/prisma/docker-compose.yml +78 -0
- package/templates/prisma/docs/adding-a-module.md +230 -0
- package/templates/prisma/docs/features-markers.md +50 -0
- package/templates/prisma/nest-cli.json +8 -0
- package/templates/prisma/package.json +95 -0
- package/templates/prisma/prisma/schema.prisma +105 -0
- package/templates/prisma/prisma/seed.ts +46 -0
- package/templates/prisma/src/app.module.ts +72 -0
- package/templates/prisma/src/auth/auth.controller.ts +283 -0
- package/templates/prisma/src/auth/auth.module.ts +59 -0
- package/templates/prisma/src/auth/auth.service.spec.ts +53 -0
- package/templates/prisma/src/auth/auth.service.ts +224 -0
- package/templates/prisma/src/auth/dto/forgot-password.dto.ts +9 -0
- package/templates/prisma/src/auth/dto/login.dto.ts +10 -0
- package/templates/prisma/src/auth/dto/refresh-token.dto.ts +9 -0
- package/templates/prisma/src/auth/dto/register.dto.ts +11 -0
- package/templates/prisma/src/auth/dto/reset-password.dto.ts +10 -0
- package/templates/prisma/src/auth/guards/github-auth.guard.ts +10 -0
- package/templates/prisma/src/auth/guards/google-auth.guard.ts +10 -0
- package/templates/prisma/src/auth/guards/jwt-auth.guard.ts +25 -0
- package/templates/prisma/src/auth/guards/session-auth.guard.spec.ts +77 -0
- package/templates/prisma/src/auth/guards/session-auth.guard.ts +37 -0
- package/templates/prisma/src/auth/session.service.spec.ts +74 -0
- package/templates/prisma/src/auth/session.service.ts +96 -0
- package/templates/prisma/src/auth/strategies/github.strategy.ts +41 -0
- package/templates/prisma/src/auth/strategies/google.strategy.ts +43 -0
- package/templates/prisma/src/auth/strategies/jwt.strategy.ts +25 -0
- package/templates/prisma/src/auth/token.service.ts +84 -0
- package/templates/prisma/src/common/constants/permissions.ts +8 -0
- package/templates/prisma/src/common/constants/role-permissions.ts +9 -0
- package/templates/prisma/src/common/decorators/current-user.decorator.ts +8 -0
- package/templates/prisma/src/common/decorators/permissions.decorator.ts +7 -0
- package/templates/prisma/src/common/decorators/public.decorator.ts +4 -0
- package/templates/prisma/src/common/decorators/roles.decorator.ts +6 -0
- package/templates/prisma/src/common/filters/http-exception.filter.ts +34 -0
- package/templates/prisma/src/common/guards/permissions.guard.spec.ts +54 -0
- package/templates/prisma/src/common/guards/permissions.guard.ts +28 -0
- package/templates/prisma/src/common/guards/roles.guard.spec.ts +37 -0
- package/templates/prisma/src/common/guards/roles.guard.ts +24 -0
- package/templates/prisma/src/common/interceptors/logging.interceptor.ts +23 -0
- package/templates/prisma/src/common/middleware/csrf.middleware.spec.ts +97 -0
- package/templates/prisma/src/common/middleware/csrf.middleware.ts +46 -0
- package/templates/prisma/src/common/utils/avatar-storage.util.ts +32 -0
- package/templates/prisma/src/common/utils/hash.util.ts +5 -0
- package/templates/prisma/src/config/env.validation.ts +49 -0
- package/templates/prisma/src/database/prisma.module.ts +9 -0
- package/templates/prisma/src/database/prisma.service.ts +13 -0
- package/templates/prisma/src/health/health.controller.ts +49 -0
- package/templates/prisma/src/health/health.module.ts +19 -0
- package/templates/prisma/src/health/indicators/prisma-health.indicator.spec.ts +22 -0
- package/templates/prisma/src/health/indicators/prisma-health.indicator.ts +19 -0
- package/templates/prisma/src/health/indicators/redis-health.indicator.spec.ts +54 -0
- package/templates/prisma/src/health/indicators/redis-health.indicator.ts +33 -0
- package/templates/prisma/src/mail/mail.module.ts +12 -0
- package/templates/prisma/src/mail/mail.processor.ts +48 -0
- package/templates/prisma/src/mail/mail.service.ts +24 -0
- package/templates/prisma/src/mail/templates/email-templates.ts +28 -0
- package/templates/prisma/src/main.ts +92 -0
- package/templates/prisma/src/metrics/metrics.controller.ts +22 -0
- package/templates/prisma/src/metrics/metrics.interceptor.ts +30 -0
- package/templates/prisma/src/metrics/metrics.module.ts +12 -0
- package/templates/prisma/src/metrics/metrics.service.ts +34 -0
- package/templates/prisma/src/types/express-session.d.ts +13 -0
- package/templates/prisma/src/users/dto/create-user.dto.ts +12 -0
- package/templates/prisma/src/users/dto/find-users-query.dto.ts +12 -0
- package/templates/prisma/src/users/dto/update-user.dto.ts +6 -0
- package/templates/prisma/src/users/entities/user.entity.ts +20 -0
- package/templates/prisma/src/users/users.controller.ts +165 -0
- package/templates/prisma/src/users/users.module.ts +10 -0
- package/templates/prisma/src/users/users.service.spec.ts +104 -0
- package/templates/prisma/src/users/users.service.ts +114 -0
- package/templates/prisma/test/auth.e2e-spec.ts +75 -0
- package/templates/prisma/test/session-auth.e2e-spec.ts +163 -0
- package/templates/prisma/test/users.e2e-spec.ts +106 -0
- package/templates/prisma/test/utils/clean-database.ts +14 -0
- package/templates/prisma/test/utils/e2e-setup.ts +58 -0
- package/templates/prisma/tsconfig.build.json +4 -0
- package/templates/prisma/tsconfig.json +25 -0
- package/templates/prisma/vitest.config.ts +20 -0
- package/templates/prisma/vitest.e2e.config.ts +19 -0
- package/templates/typeorm/.env.example +45 -0
- package/templates/typeorm/.env.test +38 -0
- package/templates/typeorm/.github/workflows/ci.yml +116 -0
- package/templates/typeorm/ARCHITECTURE.md +158 -0
- package/templates/typeorm/ARCHITECTURE.pt-BR.md +156 -0
- package/templates/typeorm/CODE_OF_CONDUCT.md +29 -0
- package/templates/typeorm/CODE_OF_CONDUCT.pt-BR.md +27 -0
- package/templates/typeorm/CONTRIBUTING.md +57 -0
- package/templates/typeorm/CONTRIBUTING.pt-BR.md +54 -0
- package/templates/typeorm/Dockerfile +43 -0
- package/templates/typeorm/LICENSE +21 -0
- package/templates/typeorm/README.md +266 -0
- package/templates/typeorm/README.pt-BR.md +266 -0
- package/templates/typeorm/ROADMAP.md +79 -0
- package/templates/typeorm/ROADMAP.pt-BR.md +67 -0
- package/templates/typeorm/TESTING.md +114 -0
- package/templates/typeorm/TESTING.pt-BR.md +114 -0
- package/templates/typeorm/docker-compose.yml +78 -0
- package/templates/typeorm/docs/adding-a-module.md +369 -0
- package/templates/typeorm/docs/features-markers.md +50 -0
- package/templates/typeorm/nest-cli.json +8 -0
- package/templates/typeorm/package.json +98 -0
- package/templates/typeorm/src/app.module.ts +72 -0
- package/templates/typeorm/src/auth/auth.controller.ts +283 -0
- package/templates/typeorm/src/auth/auth.module.ts +86 -0
- package/templates/typeorm/src/auth/auth.service.spec.ts +111 -0
- package/templates/typeorm/src/auth/auth.service.ts +346 -0
- package/templates/typeorm/src/auth/dto/forgot-password.dto.ts +9 -0
- package/templates/typeorm/src/auth/dto/login.dto.ts +10 -0
- package/templates/typeorm/src/auth/dto/refresh-token.dto.ts +9 -0
- package/templates/typeorm/src/auth/dto/register.dto.ts +11 -0
- package/templates/typeorm/src/auth/dto/reset-password.dto.ts +10 -0
- package/templates/typeorm/src/auth/entities/email-verification-token.entity.ts +69 -0
- package/templates/typeorm/src/auth/entities/oauth-account.entity.ts +50 -0
- package/templates/typeorm/src/auth/entities/password-reset-token.entity.ts +69 -0
- package/templates/typeorm/src/auth/entities/refresh-token.entity.ts +69 -0
- package/templates/typeorm/src/auth/entities/session.entity.ts +50 -0
- package/templates/typeorm/src/auth/guards/github-auth.guard.ts +10 -0
- package/templates/typeorm/src/auth/guards/google-auth.guard.ts +10 -0
- package/templates/typeorm/src/auth/guards/jwt-auth.guard.ts +25 -0
- package/templates/typeorm/src/auth/guards/session-auth.guard.spec.ts +77 -0
- package/templates/typeorm/src/auth/guards/session-auth.guard.ts +37 -0
- package/templates/typeorm/src/auth/session.service.spec.ts +74 -0
- package/templates/typeorm/src/auth/session.service.ts +96 -0
- package/templates/typeorm/src/auth/strategies/github.strategy.ts +41 -0
- package/templates/typeorm/src/auth/strategies/google.strategy.ts +43 -0
- package/templates/typeorm/src/auth/strategies/jwt.strategy.ts +25 -0
- package/templates/typeorm/src/auth/token.service.ts +115 -0
- package/templates/typeorm/src/common/constants/permissions.ts +8 -0
- package/templates/typeorm/src/common/constants/role-permissions.ts +9 -0
- package/templates/typeorm/src/common/constants/role.enum.ts +5 -0
- package/templates/typeorm/src/common/decorators/current-user.decorator.ts +8 -0
- package/templates/typeorm/src/common/decorators/permissions.decorator.ts +7 -0
- package/templates/typeorm/src/common/decorators/public.decorator.ts +4 -0
- package/templates/typeorm/src/common/decorators/roles.decorator.ts +6 -0
- package/templates/typeorm/src/common/filters/http-exception.filter.ts +34 -0
- package/templates/typeorm/src/common/guards/permissions.guard.spec.ts +54 -0
- package/templates/typeorm/src/common/guards/permissions.guard.ts +28 -0
- package/templates/typeorm/src/common/guards/roles.guard.spec.ts +37 -0
- package/templates/typeorm/src/common/guards/roles.guard.ts +24 -0
- package/templates/typeorm/src/common/interceptors/logging.interceptor.ts +23 -0
- package/templates/typeorm/src/common/middleware/csrf.middleware.spec.ts +97 -0
- package/templates/typeorm/src/common/middleware/csrf.middleware.ts +46 -0
- package/templates/typeorm/src/common/utils/avatar-storage.util.ts +32 -0
- package/templates/typeorm/src/common/utils/hash.util.ts +5 -0
- package/templates/typeorm/src/config/env.validation.ts +50 -0
- package/templates/typeorm/src/database/data-source.ts +20 -0
- package/templates/typeorm/src/database/database.module.ts +39 -0
- package/templates/typeorm/src/database/seed.ts +81 -0
- package/templates/typeorm/src/database/typeorm-options.ts +49 -0
- package/templates/typeorm/src/health/health.controller.ts +49 -0
- package/templates/typeorm/src/health/health.module.ts +19 -0
- package/templates/typeorm/src/health/indicators/redis-health.indicator.spec.ts +54 -0
- package/templates/typeorm/src/health/indicators/redis-health.indicator.ts +33 -0
- package/templates/typeorm/src/health/indicators/typeorm-health.indicator.spec.ts +49 -0
- package/templates/typeorm/src/health/indicators/typeorm-health.indicator.ts +37 -0
- package/templates/typeorm/src/mail/mail.module.ts +12 -0
- package/templates/typeorm/src/mail/mail.processor.ts +48 -0
- package/templates/typeorm/src/mail/mail.service.ts +24 -0
- package/templates/typeorm/src/mail/templates/email-templates.ts +28 -0
- package/templates/typeorm/src/main.ts +107 -0
- package/templates/typeorm/src/metrics/metrics.controller.ts +22 -0
- package/templates/typeorm/src/metrics/metrics.interceptor.ts +30 -0
- package/templates/typeorm/src/metrics/metrics.module.ts +12 -0
- package/templates/typeorm/src/metrics/metrics.service.ts +34 -0
- package/templates/typeorm/src/types/express-session.d.ts +13 -0
- package/templates/typeorm/src/users/dto/create-user.dto.ts +12 -0
- package/templates/typeorm/src/users/dto/find-users-query.dto.ts +12 -0
- package/templates/typeorm/src/users/dto/update-user.dto.ts +6 -0
- package/templates/typeorm/src/users/entities/user.entity.ts +113 -0
- package/templates/typeorm/src/users/users.controller.ts +165 -0
- package/templates/typeorm/src/users/users.module.ts +13 -0
- package/templates/typeorm/src/users/users.service.spec.ts +183 -0
- package/templates/typeorm/src/users/users.service.ts +124 -0
- package/templates/typeorm/test/auth.e2e-spec.ts +111 -0
- package/templates/typeorm/test/session-auth.e2e-spec.ts +159 -0
- package/templates/typeorm/test/users.e2e-spec.ts +183 -0
- package/templates/typeorm/test/utils/clean-database.ts +65 -0
- package/templates/typeorm/test/utils/e2e-setup.ts +77 -0
- package/templates/typeorm/tsconfig.build.json +4 -0
- package/templates/typeorm/tsconfig.json +25 -0
- package/templates/typeorm/vitest.config.ts +20 -0
- package/templates/typeorm/vitest.e2e.config.ts +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jeiel Jedson Leão Alves
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# nestforge
|
|
2
|
+
|
|
3
|
+
**English** | [Português](README.pt-BR.md)
|
|
4
|
+
|
|
5
|
+
Interactive CLI that generates NestJS projects from NestForge's [Prisma](../../templates/prisma), [TypeORM](../../templates/typeorm), and [Drizzle](../../templates/drizzle) templates.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx nestforge-generator
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For the testing guide, CLI prompts, and complete checklist, see [`TESTING.md`](TESTING.md).
|
|
12
|
+
|
|
13
|
+
## What already works
|
|
14
|
+
|
|
15
|
+
- Interactive prompts using `@clack/prompts`;
|
|
16
|
+
- TypeScript or JavaScript generation;
|
|
17
|
+
- Prisma, TypeORM, and Drizzle ORM;
|
|
18
|
+
- PostgreSQL, MySQL, and SQLite;
|
|
19
|
+
- JWT, Session/Cookies, OAuth-only, or no authentication;
|
|
20
|
+
- optional Docker;
|
|
21
|
+
- optional Swagger/OpenAPI;
|
|
22
|
+
- optional global validation with Zod;
|
|
23
|
+
- optional Redis, queues, and email;
|
|
24
|
+
- optional RBAC and Permissions;
|
|
25
|
+
- optional `.env` creation;
|
|
26
|
+
- automated tests for generated combinations.
|
|
27
|
+
|
|
28
|
+
Generated projects include features such as avatar upload, pagination, filters, health checks, metrics, unit tests, and E2E tests.
|
|
29
|
+
|
|
30
|
+
## Languages
|
|
31
|
+
|
|
32
|
+
The CLI generates projects in:
|
|
33
|
+
|
|
34
|
+
- TypeScript;
|
|
35
|
+
- JavaScript.
|
|
36
|
+
|
|
37
|
+
The JavaScript option is produced automatically from the TypeScript templates during generation.
|
|
38
|
+
|
|
39
|
+
The transformation:
|
|
40
|
+
|
|
41
|
+
- transpiles `.ts` files;
|
|
42
|
+
- removes TypeScript files that should not remain;
|
|
43
|
+
- updates `package.json` scripts;
|
|
44
|
+
- updates Vitest configuration;
|
|
45
|
+
- updates migration configuration;
|
|
46
|
+
- adapts commands according to the selected ORM.
|
|
47
|
+
|
|
48
|
+
## Available ORMs and databases
|
|
49
|
+
|
|
50
|
+
### Prisma
|
|
51
|
+
|
|
52
|
+
Available with:
|
|
53
|
+
|
|
54
|
+
- PostgreSQL;
|
|
55
|
+
- MySQL;
|
|
56
|
+
- SQLite.
|
|
57
|
+
|
|
58
|
+
The CLI adjusts the `schema.prisma` provider, database URL, and provider-specific resources.
|
|
59
|
+
|
|
60
|
+
### TypeORM
|
|
61
|
+
|
|
62
|
+
Available with:
|
|
63
|
+
|
|
64
|
+
- PostgreSQL using `pg`;
|
|
65
|
+
- MySQL using `mysql2`;
|
|
66
|
+
- SQLite using `better-sqlite3`.
|
|
67
|
+
|
|
68
|
+
The CLI adjusts:
|
|
69
|
+
|
|
70
|
+
- `DB_TYPE`;
|
|
71
|
+
- `DATABASE_URL`;
|
|
72
|
+
- column types;
|
|
73
|
+
- `DataSource` configuration;
|
|
74
|
+
- migration scripts;
|
|
75
|
+
- installed driver.
|
|
76
|
+
|
|
77
|
+
Only the required driver remains in the generated project.
|
|
78
|
+
|
|
79
|
+
### Drizzle ORM
|
|
80
|
+
|
|
81
|
+
Available with:
|
|
82
|
+
|
|
83
|
+
- PostgreSQL using `pg`;
|
|
84
|
+
- MySQL using `mysql2`;
|
|
85
|
+
- SQLite using `better-sqlite3`.
|
|
86
|
+
|
|
87
|
+
The Drizzle template includes:
|
|
88
|
+
|
|
89
|
+
- a database-specific schema;
|
|
90
|
+
- Drizzle Kit configuration;
|
|
91
|
+
- SQL migrations;
|
|
92
|
+
- seed;
|
|
93
|
+
- typed database injection;
|
|
94
|
+
- health check based on the selected driver;
|
|
95
|
+
- `DrizzleSessionStore`;
|
|
96
|
+
- transactions adapted to SQLite.
|
|
97
|
+
|
|
98
|
+
After generation, only the schema and driver for the selected database remain in the project.
|
|
99
|
+
|
|
100
|
+
## Authentication strategies
|
|
101
|
+
|
|
102
|
+
### JWT
|
|
103
|
+
|
|
104
|
+
The JWT strategy keeps:
|
|
105
|
+
|
|
106
|
+
- registration;
|
|
107
|
+
- login;
|
|
108
|
+
- access tokens;
|
|
109
|
+
- refresh tokens;
|
|
110
|
+
- refresh token rotation;
|
|
111
|
+
- revocation;
|
|
112
|
+
- logout;
|
|
113
|
+
- Google and GitHub OAuth;
|
|
114
|
+
- password recovery;
|
|
115
|
+
- email verification.
|
|
116
|
+
|
|
117
|
+
Password recovery and email verification routes depend on the Redis, queues, and email feature.
|
|
118
|
+
|
|
119
|
+
### Session/Cookies
|
|
120
|
+
|
|
121
|
+
The Session/Cookies strategy:
|
|
122
|
+
|
|
123
|
+
- keeps password registration and login;
|
|
124
|
+
- creates a session persisted in the database;
|
|
125
|
+
- sends an `httpOnly` cookie;
|
|
126
|
+
- regenerates the session after login;
|
|
127
|
+
- uses `SessionAuthGuard`;
|
|
128
|
+
- protects state-changing operations with CSRF;
|
|
129
|
+
- destroys the session on logout;
|
|
130
|
+
- starts a session after OAuth callbacks;
|
|
131
|
+
- removes JWT-only files, dependencies, and variables.
|
|
132
|
+
|
|
133
|
+
Each template uses an appropriate integration:
|
|
134
|
+
|
|
135
|
+
- Prisma uses `@quixo3/prisma-session-store`;
|
|
136
|
+
- TypeORM uses `connect-typeorm`;
|
|
137
|
+
- Drizzle uses the template's own `DrizzleSessionStore`.
|
|
138
|
+
|
|
139
|
+
### OAuth-only
|
|
140
|
+
|
|
141
|
+
The OAuth-only strategy removes password-based flows:
|
|
142
|
+
|
|
143
|
+
- `register`;
|
|
144
|
+
- `login`;
|
|
145
|
+
- `forgot-password`;
|
|
146
|
+
- `reset-password`;
|
|
147
|
+
- `verify-email`.
|
|
148
|
+
|
|
149
|
+
The following remain available:
|
|
150
|
+
|
|
151
|
+
- Google OAuth;
|
|
152
|
+
- GitHub OAuth;
|
|
153
|
+
- access tokens;
|
|
154
|
+
- refresh tokens;
|
|
155
|
+
- logout;
|
|
156
|
+
- protection for authenticated routes.
|
|
157
|
+
|
|
158
|
+
### No authentication
|
|
159
|
+
|
|
160
|
+
When “None” is selected, the CLI completely removes:
|
|
161
|
+
|
|
162
|
+
- `src/auth`;
|
|
163
|
+
- `src/users`;
|
|
164
|
+
- related DTOs;
|
|
165
|
+
- authentication guards;
|
|
166
|
+
- authentication tests;
|
|
167
|
+
- user tests.
|
|
168
|
+
|
|
169
|
+
The project keeps only the selected core, such as health checks, metrics, and infrastructure features.
|
|
170
|
+
|
|
171
|
+
## Optional features
|
|
172
|
+
|
|
173
|
+
### Docker
|
|
174
|
+
|
|
175
|
+
When Docker is disabled, the CLI removes:
|
|
176
|
+
|
|
177
|
+
- `Dockerfile`;
|
|
178
|
+
- `docker-compose.yml`.
|
|
179
|
+
|
|
180
|
+
### Swagger/OpenAPI
|
|
181
|
+
|
|
182
|
+
When Swagger is disabled, the CLI removes:
|
|
183
|
+
|
|
184
|
+
- the Swagger bootstrap from `main.ts`;
|
|
185
|
+
- the `/docs` route;
|
|
186
|
+
- decorators such as `@ApiTags`;
|
|
187
|
+
- `@ApiOperation`;
|
|
188
|
+
- `@ApiResponse`;
|
|
189
|
+
- other documentation decorators.
|
|
190
|
+
|
|
191
|
+
The Swagger/OpenAPI prompt also controls API documentation. There is no separate second option.
|
|
192
|
+
|
|
193
|
+
### Global validation
|
|
194
|
+
|
|
195
|
+
When global validation is disabled:
|
|
196
|
+
|
|
197
|
+
- `ZodValidationPipe` is not registered in `main.ts`;
|
|
198
|
+
- the pipe is not registered in the E2E setup.
|
|
199
|
+
|
|
200
|
+
DTOs remain as classes, but they are no longer automatically validated by the global pipe.
|
|
201
|
+
|
|
202
|
+
### Redis, queues, and email
|
|
203
|
+
|
|
204
|
+
When enabled, the project includes:
|
|
205
|
+
|
|
206
|
+
- Redis;
|
|
207
|
+
- BullMQ;
|
|
208
|
+
- email queues;
|
|
209
|
+
- Nodemailer;
|
|
210
|
+
- Mailpit;
|
|
211
|
+
- password recovery;
|
|
212
|
+
- email verification;
|
|
213
|
+
- Redis health check.
|
|
214
|
+
|
|
215
|
+
When disabled, related modules, routes, and dependencies are removed.
|
|
216
|
+
|
|
217
|
+
### RBAC and Permissions
|
|
218
|
+
|
|
219
|
+
When enabled, the project includes:
|
|
220
|
+
|
|
221
|
+
- `ADMIN`, `MANAGER`, and `USER` roles;
|
|
222
|
+
- granular permissions;
|
|
223
|
+
- `RolesGuard`;
|
|
224
|
+
- `PermissionsGuard`;
|
|
225
|
+
- authorization decorators.
|
|
226
|
+
|
|
227
|
+
When disabled, RBAC guards, decorators, and constants are removed. Routes still require authentication when an authentication strategy is active, but they no longer require specific permissions.
|
|
228
|
+
|
|
229
|
+
### `.env` file
|
|
230
|
+
|
|
231
|
+
When requested, the CLI automatically creates `.env` from the already processed `.env.example`.
|
|
232
|
+
|
|
233
|
+
## Option status
|
|
234
|
+
|
|
235
|
+
| Choice | Status |
|
|
236
|
+
| --- | --- |
|
|
237
|
+
| Language: TypeScript | ✅ Implemented |
|
|
238
|
+
| Language: JavaScript | ✅ Implemented |
|
|
239
|
+
| ORM: Prisma | ✅ Implemented |
|
|
240
|
+
| ORM: TypeORM | ✅ Implemented |
|
|
241
|
+
| ORM: Drizzle | ✅ Implemented |
|
|
242
|
+
| ORM: None | ❌ Not implemented |
|
|
243
|
+
| Database: PostgreSQL | ✅ Implemented |
|
|
244
|
+
| Database: MySQL | ✅ Implemented |
|
|
245
|
+
| Database: SQLite | ✅ Implemented |
|
|
246
|
+
| Database: MongoDB | ❌ Not implemented |
|
|
247
|
+
| Auth: JWT | ✅ Implemented |
|
|
248
|
+
| Auth: Session/Cookies | ✅ Implemented |
|
|
249
|
+
| Auth: OAuth-only | ✅ Implemented |
|
|
250
|
+
| Auth: None | ✅ Implemented |
|
|
251
|
+
|
|
252
|
+
The CLI rejects options that are not implemented before creating the project directory.
|
|
253
|
+
|
|
254
|
+
## Automated tests
|
|
255
|
+
|
|
256
|
+
Generator tests are located at:
|
|
257
|
+
|
|
258
|
+
```text
|
|
259
|
+
packages/cli/test/generator.test.ts
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Run them from `packages/cli`:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npm test
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Coverage includes:
|
|
269
|
+
|
|
270
|
+
- Prisma with PostgreSQL;
|
|
271
|
+
- Prisma with MySQL;
|
|
272
|
+
- Prisma with SQLite;
|
|
273
|
+
- TypeORM with SQLite;
|
|
274
|
+
- Drizzle with PostgreSQL;
|
|
275
|
+
- Drizzle with MySQL;
|
|
276
|
+
- Drizzle with SQLite;
|
|
277
|
+
- JWT;
|
|
278
|
+
- Session/Cookies;
|
|
279
|
+
- OAuth-only;
|
|
280
|
+
- no authentication;
|
|
281
|
+
- TypeScript;
|
|
282
|
+
- JavaScript;
|
|
283
|
+
- Redis removal;
|
|
284
|
+
- removal of optional features;
|
|
285
|
+
- correct database drivers;
|
|
286
|
+
- migration scripts;
|
|
287
|
+
- generated schemas;
|
|
288
|
+
- rejection of unimplemented options.
|
|
289
|
+
|
|
290
|
+
## Completed smoke tests
|
|
291
|
+
|
|
292
|
+
The following combinations were validated with installation, build, unit tests, migrations, seed, and E2E tests:
|
|
293
|
+
|
|
294
|
+
- TypeScript + TypeORM + SQLite + JWT;
|
|
295
|
+
- TypeScript + TypeORM + SQLite + Session/Cookies;
|
|
296
|
+
- TypeScript + Drizzle + SQLite + JWT;
|
|
297
|
+
- TypeScript + Drizzle + SQLite + Session/Cookies.
|
|
298
|
+
|
|
299
|
+
PostgreSQL and MySQL have automated generation, configuration, and unused-driver removal tests. Complete smoke tests for these databases still require local services or Docker.
|
|
300
|
+
|
|
301
|
+
## Known limitations
|
|
302
|
+
|
|
303
|
+
### Redis in earlier templates
|
|
304
|
+
|
|
305
|
+
In the Prisma and TypeORM templates, `docker-compose.yml` and environment files may still keep Redis and Mailpit services or variables when the feature is disabled.
|
|
306
|
+
|
|
307
|
+
This extra content does not prevent the project from compiling or running, but it can still be cleaned up to make generation completely minimal.
|
|
308
|
+
|
|
309
|
+
### No authentication with Prisma
|
|
310
|
+
|
|
311
|
+
In the Prisma template, `schema.prisma` still keeps models such as `User`, `RefreshToken`, and `OAuthAccount` when no authentication is selected.
|
|
312
|
+
|
|
313
|
+
`prisma/seed.ts` may also remain related to the demonstration users.
|
|
314
|
+
|
|
315
|
+
The application code is removed correctly, but the schema may still create tables that are not used.
|
|
316
|
+
|
|
317
|
+
### Administrative creation with OAuth-only
|
|
318
|
+
|
|
319
|
+
With OAuth-only, the administrative `POST /users` endpoint still allows a user to be created manually.
|
|
320
|
+
|
|
321
|
+
The CLI does not yet distinguish the strategy used for login from how an administrator registers users through a management interface.
|
|
322
|
+
|
|
323
|
+
## Local development
|
|
324
|
+
|
|
325
|
+
From the monorepo root:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
npm install
|
|
329
|
+
cd packages/cli
|
|
330
|
+
npm run dev
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`npm run dev` runs the CLI directly from TypeScript using `tsx`.
|
|
334
|
+
|
|
335
|
+
To run the tests:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
npm test
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
To test the CLI as an installed package:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
npm run build
|
|
345
|
+
npm link
|
|
346
|
+
nestforge
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Publishing
|
|
350
|
+
|
|
351
|
+
From `packages/cli`:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
npm run build
|
|
355
|
+
npm pack --dry-run
|
|
356
|
+
npm publish
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
The build:
|
|
360
|
+
|
|
361
|
+
1. compiles the CLI;
|
|
362
|
+
2. copies the Prisma, TypeORM, and Drizzle templates;
|
|
363
|
+
3. prepares the package published to npm.
|
|
364
|
+
|
|
365
|
+
## Next steps
|
|
366
|
+
|
|
367
|
+
- an option without an ORM;
|
|
368
|
+
- MongoDB;
|
|
369
|
+
- more complete project and package name validation;
|
|
370
|
+
- expand the smoke-test matrix with real PostgreSQL and MySQL services;
|
|
371
|
+
- reduce the known limitations in the earlier templates.
|