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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
NODE_ENV=test
|
|
2
|
+
PORT=3000
|
|
3
|
+
APP_URL=http://localhost:3000
|
|
4
|
+
CORS_ORIGINS=http://localhost:5173
|
|
5
|
+
|
|
6
|
+
# Banco isolado, nunca o de desenvolvimento
|
|
7
|
+
DATABASE_URL="postgresql://nestforge:nestforge@localhost:5432/nestforge_test?schema=public"
|
|
8
|
+
|
|
9
|
+
# nestforge:feature:auth:token
|
|
10
|
+
JWT_ACCESS_SECRET=test-access-secret-0123456789
|
|
11
|
+
JWT_ACCESS_EXPIRES_IN=15m
|
|
12
|
+
JWT_REFRESH_SECRET=test-refresh-secret-0123456789
|
|
13
|
+
JWT_REFRESH_EXPIRES_IN=7d
|
|
14
|
+
# nestforge:feature:auth:token:end
|
|
15
|
+
|
|
16
|
+
GOOGLE_CLIENT_ID=test-google-client-id
|
|
17
|
+
GOOGLE_CLIENT_SECRET=test-google-client-secret
|
|
18
|
+
GITHUB_CLIENT_ID=test-github-client-id
|
|
19
|
+
GITHUB_CLIENT_SECRET=test-github-client-secret
|
|
20
|
+
|
|
21
|
+
REDIS_HOST=localhost
|
|
22
|
+
REDIS_PORT=6379
|
|
23
|
+
|
|
24
|
+
MAIL_HOST=localhost
|
|
25
|
+
MAIL_PORT=1025
|
|
26
|
+
MAIL_FROM="NestForge <no-reply@nestforge.dev>"
|
|
27
|
+
|
|
28
|
+
# limite bem mais alto pra não interferir nos testes
|
|
29
|
+
THROTTLE_TTL=60
|
|
30
|
+
THROTTLE_LIMIT=1000
|
|
31
|
+
|
|
32
|
+
# nestforge:feature:auth:session
|
|
33
|
+
SESSION_SECRET=test-session-secret-01234567890123456789
|
|
34
|
+
SESSION_MAX_AGE=604800000
|
|
35
|
+
|
|
36
|
+
ENABLE_CSRF=true
|
|
37
|
+
# nestforge:feature:auth:session:end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build-test-lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
services:
|
|
14
|
+
# nestforge:feature:database:postgres
|
|
15
|
+
postgres:
|
|
16
|
+
image: postgres:16-alpine
|
|
17
|
+
env:
|
|
18
|
+
POSTGRES_USER: nestforge
|
|
19
|
+
POSTGRES_PASSWORD: nestforge
|
|
20
|
+
POSTGRES_DB: nestforge
|
|
21
|
+
ports:
|
|
22
|
+
- 5432:5432
|
|
23
|
+
options: >-
|
|
24
|
+
--health-cmd pg_isready
|
|
25
|
+
--health-interval 10s
|
|
26
|
+
--health-timeout 5s
|
|
27
|
+
--health-retries 5
|
|
28
|
+
# nestforge:feature:database:postgres:end
|
|
29
|
+
|
|
30
|
+
# nestforge:feature:database:mysql
|
|
31
|
+
mysql:
|
|
32
|
+
image: mysql:8
|
|
33
|
+
env:
|
|
34
|
+
MYSQL_USER: nestforge
|
|
35
|
+
MYSQL_PASSWORD: nestforge
|
|
36
|
+
MYSQL_ROOT_PASSWORD: nestforge
|
|
37
|
+
MYSQL_DATABASE: nestforge
|
|
38
|
+
ports:
|
|
39
|
+
- 3306:3306
|
|
40
|
+
options: >-
|
|
41
|
+
--health-cmd "mysqladmin ping -h localhost"
|
|
42
|
+
--health-interval 10s
|
|
43
|
+
--health-timeout 5s
|
|
44
|
+
--health-retries 5
|
|
45
|
+
# nestforge:feature:database:mysql:end
|
|
46
|
+
|
|
47
|
+
redis:
|
|
48
|
+
image: redis:7-alpine
|
|
49
|
+
ports:
|
|
50
|
+
- 6379:6379
|
|
51
|
+
options: >-
|
|
52
|
+
--health-cmd "redis-cli ping"
|
|
53
|
+
--health-interval 10s
|
|
54
|
+
--health-timeout 5s
|
|
55
|
+
--health-retries 5
|
|
56
|
+
|
|
57
|
+
env:
|
|
58
|
+
# nestforge:feature:database:postgres
|
|
59
|
+
DATABASE_URL: postgresql://nestforge:nestforge@localhost:5432/nestforge?schema=public
|
|
60
|
+
# nestforge:feature:database:postgres:end
|
|
61
|
+
# nestforge:feature:database:mysql
|
|
62
|
+
DATABASE_URL: mysql://nestforge:nestforge@localhost:3306/nestforge
|
|
63
|
+
# nestforge:feature:database:mysql:end
|
|
64
|
+
# nestforge:feature:database:sqlite
|
|
65
|
+
DATABASE_URL: file:./ci-dev.db
|
|
66
|
+
# nestforge:feature:database:sqlite:end
|
|
67
|
+
JWT_ACCESS_SECRET: ci-access-secret-0123456789
|
|
68
|
+
JWT_REFRESH_SECRET: ci-refresh-secret-0123456789
|
|
69
|
+
|
|
70
|
+
steps:
|
|
71
|
+
- name: Checkout
|
|
72
|
+
uses: actions/checkout@v4
|
|
73
|
+
|
|
74
|
+
- name: Setup Node
|
|
75
|
+
uses: actions/setup-node@v4
|
|
76
|
+
with:
|
|
77
|
+
node-version: 20
|
|
78
|
+
cache: npm
|
|
79
|
+
|
|
80
|
+
- name: Instalar dependências
|
|
81
|
+
run: npm ci
|
|
82
|
+
|
|
83
|
+
- name: Gerar Prisma Client
|
|
84
|
+
run: npx prisma generate
|
|
85
|
+
|
|
86
|
+
- name: Rodar migrations
|
|
87
|
+
run: npx prisma migrate deploy
|
|
88
|
+
|
|
89
|
+
- name: Lint
|
|
90
|
+
run: npm run lint
|
|
91
|
+
|
|
92
|
+
- name: Build
|
|
93
|
+
run: npm run build
|
|
94
|
+
|
|
95
|
+
- name: Testes
|
|
96
|
+
run: npm run test
|
|
97
|
+
|
|
98
|
+
# nestforge:feature:database:postgres
|
|
99
|
+
- name: Criar banco de teste
|
|
100
|
+
run: PGPASSWORD=nestforge psql -h localhost -U nestforge -d nestforge -c "CREATE DATABASE nestforge_test;"
|
|
101
|
+
# nestforge:feature:database:postgres:end
|
|
102
|
+
|
|
103
|
+
# nestforge:feature:database:mysql
|
|
104
|
+
- name: Criar banco de teste
|
|
105
|
+
run: mysql -h 127.0.0.1 -u root -pnestforge -e "CREATE DATABASE IF NOT EXISTS nestforge_test;"
|
|
106
|
+
# nestforge:feature:database:mysql:end
|
|
107
|
+
|
|
108
|
+
- name: Testes e2e
|
|
109
|
+
run: npm run test:e2e
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
**English** | [Português](ARCHITECTURE.pt-BR.md)
|
|
4
|
+
|
|
5
|
+
This document explains how NestForge is organized and why certain design decisions were made. The goal is for someone new to the project to understand the “why,” not only the “what.”
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Request → main.ts (global pipes/filters/interceptors)
|
|
11
|
+
→ Guards (JwtAuthGuard → RolesGuard → PermissionsGuard)
|
|
12
|
+
→ Controller (validates through a Zod DTO, delegates to the service)
|
|
13
|
+
→ Service (business rules, calls Prisma)
|
|
14
|
+
→ Prisma → PostgreSQL
|
|
15
|
+
→ Response (passes through ClassSerializerInterceptor before becoming JSON)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Each domain module (`auth`, `users`, `mail`, `health`, `metrics`) follows the same structure:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
<module>/
|
|
22
|
+
├── dto/ # input — one Zod schema + createZodDto per DTO
|
|
23
|
+
├── entities/ # output — classes with @Exclude() for sensitive fields
|
|
24
|
+
├── <module>.controller.ts # orchestrates only: receives request, calls service, returns
|
|
25
|
+
├── <module>.service.ts # actual business rules
|
|
26
|
+
└── <module>.module.ts # wires everything together and declares exports
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Controllers never communicate with Prisma directly — they always go through the service. This keeps business logic testable without starting the entire application (which is why unit tests mock only Prisma, not all of Nest).
|
|
30
|
+
|
|
31
|
+
## Design decisions (short ADR)
|
|
32
|
+
|
|
33
|
+
### Why Zod (with `nestjs-zod`) instead of `class-validator`?
|
|
34
|
+
|
|
35
|
+
`class-validator` requires duplicated information: validation decorators (`@IsEmail()`) and documentation decorators (`@ApiProperty()`) describe the same thing in two different ways, and one can easily become outdated relative to the other. With Zod, the schema is the single source of truth — `nestjs-zod` generates the DTO and Swagger documentation from it. See `src/*/dto/*.dto.ts` and `patchNestJsSwagger()` in `src/main.ts`.
|
|
36
|
+
|
|
37
|
+
### Why Prisma without a repository layer on top?
|
|
38
|
+
|
|
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
|
+
|
|
41
|
+
### Why are permissions a fixed map in code (`ROLE_PERMISSIONS`) instead of a database table?
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
### Why BullMQ for email instead of sending it directly in the request?
|
|
46
|
+
|
|
47
|
+
Sending email is a network operation (SMTP) that can fail or take time. If it happened inside `POST /auth/register`, instability in the email provider would make registration slow or show an error even when the account had been created. The queue decouples these operations: the request responds as soon as the job is queued, and `MailProcessor` handles delivery (with retries) in the background.
|
|
48
|
+
|
|
49
|
+
### Why store hashed refresh tokens in the database instead of trusting only the JWT?
|
|
50
|
+
|
|
51
|
+
A JWT cannot be revoked before it expires. Storing the refresh token hash in the database makes it possible to invalidate sessions properly (logout, password change, stolen refresh token) — this is why `resetPassword` revokes all active refresh tokens for the user.
|
|
52
|
+
|
|
53
|
+
### Why use `UserEntity` + `ClassSerializerInterceptor` instead of only a Prisma `select`?
|
|
54
|
+
|
|
55
|
+
Both intentionally coexist. The `select` avoids unnecessarily retrieving `passwordHash` from the database; `@Exclude()` on the entity is a second barrier — even if a future query forgets the `select`, the field does not escape into the HTTP response. This is defense in depth, not redundancy.
|
|
56
|
+
|
|
57
|
+
### Why is CSRF disabled by default?
|
|
58
|
+
|
|
59
|
+
The API uses a Bearer token in the `Authorization` header, not a session cookie. CSRF exploits the browser automatically sending cookies across origins, which does not apply here. The middleware is ready in `src/common/middleware/csrf.middleware.ts` for projects that adapt the starter to store the token in a cookie.
|
|
60
|
+
|
|
61
|
+
## Authentication flow in detail
|
|
62
|
+
|
|
63
|
+
1. `POST /auth/register` or `/login` → `AuthService` generates an `accessToken` (15 min) + `refreshToken` (7 days) pair and stores the refresh token hash in the database.
|
|
64
|
+
2. Protected routes pass through `JwtAuthGuard`, which validates the `accessToken` and populates `req.user` with `{ id, email, role }` through `JwtStrategy`.
|
|
65
|
+
3. `RolesGuard` and `PermissionsGuard` read `req.user.role` and decide whether to allow the route using its `@Roles()` / `@Permissions()` decorators.
|
|
66
|
+
4. When the `accessToken` expires, the client calls `POST /auth/refresh` — the old refresh token is revoked and a new pair is issued (token rotation).
|
|
67
|
+
|
|
68
|
+
## Where to add something new
|
|
69
|
+
|
|
70
|
+
If you are adding a new feature (rather than only changing auth/users), see [`docs/adding-a-module.md`](docs/adding-a-module.md) — it is a step-by-step guide that applies the conventions above to a module built from scratch.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Arquitetura
|
|
2
|
+
|
|
3
|
+
[English](ARCHITECTURE.md) | **Português**
|
|
4
|
+
|
|
5
|
+
Este documento explica como o NestForge está organizado e por que certas decisões de design foram tomadas. O objetivo é que alguém novo no projeto consiga entender o "porquê", não só o "o quê".
|
|
6
|
+
|
|
7
|
+
## Visão geral
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Request → main.ts (pipes/filters/interceptors globais)
|
|
11
|
+
→ Guards (JwtAuthGuard → RolesGuard → PermissionsGuard)
|
|
12
|
+
→ Controller (valida via DTO Zod, delega pro service)
|
|
13
|
+
→ Service (regra de negócio, chama o Prisma)
|
|
14
|
+
→ Prisma → PostgreSQL
|
|
15
|
+
→ Response (passa pelo ClassSerializerInterceptor antes de virar JSON)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Cada módulo de domínio (`auth`, `users`, `mail`, `health`, `metrics`) segue a mesma forma:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
<modulo>/
|
|
22
|
+
├── dto/ # entrada — um schema Zod + createZodDto por DTO
|
|
23
|
+
├── entities/ # saída — classes com @Exclude() pra campos sensíveis
|
|
24
|
+
├── <modulo>.controller.ts # só orquestra: recebe request, chama o service, devolve
|
|
25
|
+
├── <modulo>.service.ts # regra de negócio de verdade
|
|
26
|
+
└── <modulo>.module.ts # amarra tudo e declara o que exporta
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Controllers nunca falam com o Prisma diretamente — sempre passam pelo service. Isso mantém a lógica de negócio testável sem precisar subir a aplicação inteira (é por isso que os testes unitários mockam só o Prisma, não o Nest todo).
|
|
30
|
+
|
|
31
|
+
## Decisões de design (ADR curto)
|
|
32
|
+
|
|
33
|
+
### Por que Zod (com `nestjs-zod`) em vez de `class-validator`?
|
|
34
|
+
`class-validator` obriga a duplicar informação: os decorators de validação (`@IsEmail()`) e os decorators de documentação (`@ApiProperty()`) descrevem a mesma coisa de duas formas diferentes, e é fácil um ficar desatualizado em relação ao outro. Com Zod, o schema é a única fonte de verdade — `nestjs-zod` gera o DTO e o Swagger a partir dele. Ver `src/*/dto/*.dto.ts` e `patchNestJsSwagger()` em `src/main.ts`.
|
|
35
|
+
|
|
36
|
+
### Por que Prisma sem uma camada de "repository" por cima?
|
|
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
|
+
|
|
39
|
+
### Por que permissions são um mapa fixo em código (`ROLE_PERMISSIONS`) e não uma tabela no banco?
|
|
40
|
+
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
|
+
|
|
42
|
+
### Por que BullMQ para e-mails, e não enviar direto na request?
|
|
43
|
+
Enviar e-mail é uma chamada de rede (SMTP) que pode falhar ou demorar — se isso acontecesse dentro do `POST /auth/register`, uma instabilidade no provedor de e-mail deixaria o cadastro lento ou o usuário veria erro mesmo com a conta criada. A fila desacopla isso: a request responde assim que o job é enfileirado, e o `MailProcessor` cuida do envio (com retry) em segundo plano.
|
|
44
|
+
|
|
45
|
+
### Por que refresh tokens ficam no banco (hasheados) em vez de só confiar no JWT?
|
|
46
|
+
Um JWT sozinho não pode ser revogado antes de expirar. Guardar o hash do refresh token no banco permite invalidar sessões de verdade (logout, troca de senha, refresh token roubado) — é por isso que `resetPassword` revoga todos os refresh tokens ativos do usuário.
|
|
47
|
+
|
|
48
|
+
### Por que `UserEntity` + `ClassSerializerInterceptor` em vez de só um `select` no Prisma?
|
|
49
|
+
As duas coisas coexistem de propósito. O `select` evita trazer o `passwordHash` do banco desnecessariamente; o `@Exclude()` na entidade é uma segunda barreira — mesmo que uma query futura esqueça o `select`, o campo não escapa pra resposta HTTP. Defesa em profundidade, não redundância.
|
|
50
|
+
|
|
51
|
+
### Por que CSRF vem desligado por padrão?
|
|
52
|
+
A API usa Bearer token no header `Authorization`, não cookie de sessão. CSRF explora o fato do navegador enviar cookies automaticamente entre origens — isso não se aplica aqui. O middleware existe pronto (`src/common/middleware/csrf.middleware.ts`) pra quem adaptar o boilerplate pra guardar token em cookie.
|
|
53
|
+
|
|
54
|
+
## Fluxo de autenticação, em detalhe
|
|
55
|
+
|
|
56
|
+
1. `POST /auth/register` ou `/login` → `AuthService` gera um par `accessToken` (15min) + `refreshToken` (7 dias), e guarda o hash do refresh no banco.
|
|
57
|
+
2. Rotas protegidas passam pelo `JwtAuthGuard`, que valida o `accessToken` e popula `req.user` com `{ id, email, role }` (via `JwtStrategy`).
|
|
58
|
+
3. `RolesGuard` e `PermissionsGuard` leem `req.user.role` e decidem se a rota é liberada, usando os decorators `@Roles()` / `@Permissions()` da rota.
|
|
59
|
+
4. Quando o `accessToken` expira, o client chama `POST /auth/refresh` — o refresh token antigo é revogado e um novo par é emitido (rotação de token).
|
|
60
|
+
|
|
61
|
+
## Onde adicionar coisa nova
|
|
62
|
+
|
|
63
|
+
Se você está adicionando um recurso novo (não só mexendo em auth/users), veja [`docs/adding-a-module.md`](docs/adding-a-module.md) — é um passo a passo praticando as convenções acima num módulo do zero.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
**English** | [Português](CODE_OF_CONDUCT.pt-BR.md)
|
|
4
|
+
|
|
5
|
+
## Our commitment
|
|
6
|
+
|
|
7
|
+
We, as members, contributors, and maintainers, pledge to make participation in this project a harassment-free experience for everyone, regardless of age, body, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual orientation.
|
|
8
|
+
|
|
9
|
+
## Our standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment:
|
|
12
|
+
|
|
13
|
+
- Using welcoming and inclusive language
|
|
14
|
+
- Respecting different viewpoints and experiences
|
|
15
|
+
- Gracefully accepting constructive criticism
|
|
16
|
+
- Focusing on what is best for the community
|
|
17
|
+
|
|
18
|
+
Examples of unacceptable behavior:
|
|
19
|
+
|
|
20
|
+
- The use of sexualized language or imagery
|
|
21
|
+
- Offensive comments or personal/political attacks
|
|
22
|
+
- Public or private harassment
|
|
23
|
+
- Publishing other people's private information without permission
|
|
24
|
+
|
|
25
|
+
## Enforcement
|
|
26
|
+
|
|
27
|
+
Instances of abusive behavior may be reported by opening an issue marked as confidential or by contacting the project maintainer directly. All complaints will be reviewed and investigated.
|
|
28
|
+
|
|
29
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Código de Conduta
|
|
2
|
+
|
|
3
|
+
[English](CODE_OF_CONDUCT.md) | **Português**
|
|
4
|
+
|
|
5
|
+
## Nosso compromisso
|
|
6
|
+
|
|
7
|
+
Nós, como membros, contribuintes e mantenedores, nos comprometemos a fazer da participação neste projeto uma experiência livre de assédio para todos, independentemente de idade, corpo, deficiência, etnia, identidade e expressão de gênero, nível de experiência, nacionalidade, aparência pessoal, raça, religião ou orientação sexual.
|
|
8
|
+
|
|
9
|
+
## Nossos padrões
|
|
10
|
+
|
|
11
|
+
Exemplos de comportamento que contribuem para um ambiente positivo:
|
|
12
|
+
- Usar linguagem acolhedora e inclusiva
|
|
13
|
+
- Respeitar pontos de vista e experiências diferentes
|
|
14
|
+
- Aceitar críticas construtivas com elegância
|
|
15
|
+
- Focar no que é melhor para a comunidade
|
|
16
|
+
|
|
17
|
+
Exemplos de comportamento inaceitável:
|
|
18
|
+
- Uso de linguagem ou imagens sexualizadas
|
|
19
|
+
- Comentários ofensivos ou ataques pessoais/políticos
|
|
20
|
+
- Assédio público ou privado
|
|
21
|
+
- Publicar informações privadas de terceiros sem permissão
|
|
22
|
+
|
|
23
|
+
## Aplicação
|
|
24
|
+
|
|
25
|
+
Casos de comportamento abusivo podem ser reportados abrindo uma issue marcada como confidencial ou entrando em contato diretamente com o mantenedor do projeto. Todas as reclamações serão revisadas e investigadas.
|
|
26
|
+
|
|
27
|
+
Este Código de Conduta é adaptado do [Contributor Covenant](https://www.contributor-covenant.org), versão 2.1.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Contributing to NestForge
|
|
2
|
+
|
|
3
|
+
**English** | [Português](CONTRIBUTING.pt-BR.md)
|
|
4
|
+
|
|
5
|
+
Thank you for considering contributing! 🎉
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
1. Fork the repository
|
|
10
|
+
2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/nestforge.git`
|
|
11
|
+
3. Create a branch: `git checkout -b feat/feature-name`
|
|
12
|
+
4. Start the environment: `docker compose up` (or `npm install` + `npm run start:dev`)
|
|
13
|
+
5. Make your changes
|
|
14
|
+
6. Run tests and lint before committing: `npm run test && npm run lint`
|
|
15
|
+
7. Commit according to the convention below
|
|
16
|
+
8. Open a Pull Request describing what was changed and why
|
|
17
|
+
|
|
18
|
+
## Commit convention
|
|
19
|
+
|
|
20
|
+
We use Portuguese commit messages following [Conventional Commits](https://www.conventionalcommits.org/):
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
feat: adiciona autenticação via Google OAuth
|
|
24
|
+
fix: corrige validação do refresh token
|
|
25
|
+
docs: atualiza guia de instalação
|
|
26
|
+
test: adiciona testes de integração para users
|
|
27
|
+
refactor: extrai lógica de hash para utils
|
|
28
|
+
chore: atualiza dependências
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Code standards
|
|
32
|
+
|
|
33
|
+
- If your code is related to an optional CLI feature (Swagger, Redis, RBAC, etc.), mark it according to [`docs/feature-markers.md`](docs/feature-markers.md). Without this, the CLI cannot remove the code when someone disables the feature.
|
|
34
|
+
- Strict TypeScript (no unjustified `any`)
|
|
35
|
+
- Always validate input through Zod (DTOs)
|
|
36
|
+
- No business logic in controllers — controllers only orchestrate, services handle the logic
|
|
37
|
+
- Every new route requires Swagger decorators (`@ApiTags`, `@ApiOperation`, etc.)
|
|
38
|
+
- Every new feature requires tests (at least unit tests)
|
|
39
|
+
|
|
40
|
+
## Reporting bugs
|
|
41
|
+
|
|
42
|
+
Open an issue containing:
|
|
43
|
+
|
|
44
|
+
- A description of the problem
|
|
45
|
+
- Steps to reproduce it
|
|
46
|
+
- Expected versus actual behavior
|
|
47
|
+
- Node version / environment (Docker or local)
|
|
48
|
+
|
|
49
|
+
## Suggesting features
|
|
50
|
+
|
|
51
|
+
Before implementing, open an issue with the `enhancement` label describing the problem the feature solves. This avoids rework if the approach needs to be discussed.
|
|
52
|
+
|
|
53
|
+
## Code of Conduct
|
|
54
|
+
|
|
55
|
+
By contributing, you agree to follow the project's [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
56
|
+
|
|
57
|
+
---
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Contribuindo com o NestForge
|
|
2
|
+
|
|
3
|
+
[English](CONTRIBUTING.md) | **Português**
|
|
4
|
+
|
|
5
|
+
Obrigado por considerar contribuir! 🎉
|
|
6
|
+
|
|
7
|
+
## Como começar
|
|
8
|
+
|
|
9
|
+
1. Faça um fork do repositório
|
|
10
|
+
2. Clone o seu fork: `git clone https://github.com/SEU_USUARIO/nestforge.git`
|
|
11
|
+
3. Crie uma branch: `git checkout -b feat/nome-da-feature`
|
|
12
|
+
4. Suba o ambiente: `docker compose up` (ou `npm install` + `npm run start:dev`)
|
|
13
|
+
5. Faça suas alterações
|
|
14
|
+
6. Rode os testes e o lint antes de commitar: `npm run test && npm run lint`
|
|
15
|
+
7. Commit seguindo o padrão abaixo
|
|
16
|
+
8. Abra um Pull Request descrevendo o que foi feito e por quê
|
|
17
|
+
|
|
18
|
+
## Padrão de commits
|
|
19
|
+
|
|
20
|
+
Usamos commits em português, seguindo [Conventional Commits](https://www.conventionalcommits.org/):
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
feat: adiciona autenticação via Google OAuth
|
|
24
|
+
fix: corrige validação do refresh token
|
|
25
|
+
docs: atualiza guia de instalação
|
|
26
|
+
test: adiciona testes de integração para users
|
|
27
|
+
refactor: extrai lógica de hash para utils
|
|
28
|
+
chore: atualiza dependências
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Padrões de código
|
|
32
|
+
|
|
33
|
+
- Se o seu código for ligado a um recurso opcional da CLI (Swagger, Redis, RBAC, etc.), marque ele seguindo [`docs/feature-markers.md`](docs/feature-markers.md) — sem isso, a CLI não consegue remover o trecho quando alguém desliga o recurso.
|
|
34
|
+
- TypeScript estrito (sem `any` sem justificativa)
|
|
35
|
+
- Validação de entrada sempre via Zod (DTOs)
|
|
36
|
+
- Nada de lógica de negócio no controller — controller só orquestra, service resolve
|
|
37
|
+
- Toda rota nova precisa de decorators de Swagger (`@ApiTags`, `@ApiOperation`, etc)
|
|
38
|
+
- Toda feature nova precisa de teste (unitário no mínimo)
|
|
39
|
+
|
|
40
|
+
## Reportando bugs
|
|
41
|
+
|
|
42
|
+
Abra uma issue com:
|
|
43
|
+
- Descrição do problema
|
|
44
|
+
- Passos para reproduzir
|
|
45
|
+
- Comportamento esperado vs. atual
|
|
46
|
+
- Versão do Node / ambiente (Docker ou local)
|
|
47
|
+
|
|
48
|
+
## Sugerindo features
|
|
49
|
+
|
|
50
|
+
Abra uma issue com a tag `enhancement` descrevendo o problema que a feature resolve antes de sair implementando — isso evita retrabalho caso a abordagem precise ser discutida.
|
|
51
|
+
|
|
52
|
+
## Código de conduta
|
|
53
|
+
|
|
54
|
+
Ao contribuir, você concorda em seguir o [Código de Conduta](CODE_OF_CONDUCT.pt-BR.md) do projeto.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# --- Base ---
|
|
2
|
+
FROM node:20-alpine AS base
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
COPY package*.json ./
|
|
5
|
+
COPY prisma ./prisma
|
|
6
|
+
|
|
7
|
+
# --- Dependencies ---
|
|
8
|
+
FROM base AS deps
|
|
9
|
+
RUN npm ci
|
|
10
|
+
|
|
11
|
+
# --- Development ---
|
|
12
|
+
FROM deps AS development
|
|
13
|
+
COPY . .
|
|
14
|
+
RUN npx prisma generate
|
|
15
|
+
EXPOSE 3000
|
|
16
|
+
CMD ["npm", "run", "start:dev"]
|
|
17
|
+
|
|
18
|
+
# --- Build ---
|
|
19
|
+
FROM deps AS build
|
|
20
|
+
COPY . .
|
|
21
|
+
RUN npx prisma generate
|
|
22
|
+
RUN npm run build
|
|
23
|
+
RUN npm prune --production
|
|
24
|
+
|
|
25
|
+
# --- Production ---
|
|
26
|
+
FROM node:20-alpine AS production
|
|
27
|
+
WORKDIR /app
|
|
28
|
+
ENV NODE_ENV=production
|
|
29
|
+
COPY --from=build /app/node_modules ./node_modules
|
|
30
|
+
COPY --from=build /app/dist ./dist
|
|
31
|
+
COPY --from=build /app/prisma ./prisma
|
|
32
|
+
EXPOSE 3000
|
|
33
|
+
CMD ["node", "dist/main.js"]
|
|
@@ -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.
|