@node-initializr/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.
Files changed (152) hide show
  1. package/dist/generate.d.ts +12 -0
  2. package/dist/generate.js +77 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.js +14 -0
  5. package/dist/template-engine.d.ts +24 -0
  6. package/dist/template-engine.js +472 -0
  7. package/dist/templates/arch-clean/express/src/application/use-cases/get-users.use-case.hbs +39 -0
  8. package/dist/templates/arch-clean/express/src/config/env.hbs +4 -0
  9. package/dist/templates/arch-clean/express/src/domain/entities/user.entity.hbs +7 -0
  10. package/dist/templates/arch-clean/express/src/index.hbs +66 -0
  11. package/dist/templates/arch-clean/express/src/infrastructure/http/health.routes.hbs +7 -0
  12. package/dist/templates/arch-clean/express/src/infrastructure/http/users.routes.hbs +9 -0
  13. package/dist/templates/arch-clean/express/src/shared/errors/app.error.hbs +5 -0
  14. package/dist/templates/arch-clean/fastify/src/application/use-cases/get-users.use-case.hbs +39 -0
  15. package/dist/templates/arch-clean/fastify/src/domain/entities/user.entity.hbs +7 -0
  16. package/dist/templates/arch-clean/fastify/src/index.hbs +53 -0
  17. package/dist/templates/arch-clean/fastify/src/infrastructure/http/routes.hbs +8 -0
  18. package/dist/templates/arch-clean/fastify/src/shared/errors/app.error.hbs +5 -0
  19. package/dist/templates/arch-clean/nestjs/src/app.module.ts.hbs +58 -0
  20. package/dist/templates/arch-clean/nestjs/src/application/use-cases/get-users.use-case.ts.hbs +14 -0
  21. package/dist/templates/arch-clean/nestjs/src/config/config.module.ts.hbs +4 -0
  22. package/dist/templates/arch-clean/nestjs/src/domain/entities/user.entity.ts.hbs +7 -0
  23. package/dist/templates/arch-clean/nestjs/src/domain/repositories/user.repository.ts.hbs +7 -0
  24. package/dist/templates/arch-clean/nestjs/src/infrastructure/http/health.controller.ts.hbs +11 -0
  25. package/dist/templates/arch-clean/nestjs/src/infrastructure/http/users.controller.ts.hbs +22 -0
  26. package/dist/templates/arch-clean/nestjs/src/infrastructure/persistence/drizzle-user.repository.ts.hbs +15 -0
  27. package/dist/templates/arch-clean/nestjs/src/infrastructure/persistence/in-memory-user.repository.ts.hbs +10 -0
  28. package/dist/templates/arch-clean/nestjs/src/infrastructure/persistence/prisma-user.repository.ts.hbs +14 -0
  29. package/dist/templates/arch-clean/nestjs/src/infrastructure/persistence/sequelize-user.repository.ts.hbs +18 -0
  30. package/dist/templates/arch-clean/nestjs/src/infrastructure/persistence/typeorm-user.repository.ts.hbs +19 -0
  31. package/dist/templates/arch-clean/nestjs/src/infrastructure/prisma/prisma.module.ts.hbs +6 -0
  32. package/dist/templates/arch-clean/nestjs/src/infrastructure/prisma/prisma.service.ts.hbs +8 -0
  33. package/dist/templates/arch-clean/nestjs/src/main.ts.hbs +21 -0
  34. package/dist/templates/arch-clean/nestjs/src/shared/errors/app.error.ts.hbs +9 -0
  35. package/dist/templates/arch-clean/nestjs/tests/health.spec.ts.hbs +17 -0
  36. package/dist/templates/arch-modular/express/src/index.hbs +46 -0
  37. package/dist/templates/arch-modular/express/src/infra/database.hbs +3 -0
  38. package/dist/templates/arch-modular/express/src/modules/health/health.routes.hbs +7 -0
  39. package/dist/templates/arch-modular/express/src/modules/users/users.routes.hbs +55 -0
  40. package/dist/templates/arch-modular/express/src/shared/constants.hbs +1 -0
  41. package/dist/templates/arch-modular/fastify/src/index.hbs +33 -0
  42. package/dist/templates/arch-modular/fastify/src/infra/database.hbs +3 -0
  43. package/dist/templates/arch-modular/fastify/src/modules/health/health.routes.hbs +9 -0
  44. package/dist/templates/arch-modular/fastify/src/modules/users/users.routes.hbs +48 -0
  45. package/dist/templates/arch-modular/fastify/src/shared/constants.hbs +1 -0
  46. package/dist/templates/arch-modular/nestjs/src/app.module.ts.hbs +63 -0
  47. package/dist/templates/arch-modular/nestjs/src/config/config.module.ts.hbs +4 -0
  48. package/dist/templates/arch-modular/nestjs/src/infra/prisma/prisma.module.ts.hbs +9 -0
  49. package/dist/templates/arch-modular/nestjs/src/infra/prisma/prisma.service.ts.hbs +13 -0
  50. package/dist/templates/arch-modular/nestjs/src/main.ts.hbs +28 -0
  51. package/dist/templates/arch-modular/nestjs/src/modules/health/health.controller.ts.hbs +17 -0
  52. package/dist/templates/arch-modular/nestjs/src/modules/health/health.module.ts.hbs +7 -0
  53. package/dist/templates/arch-modular/nestjs/src/modules/users/users.controller.ts.hbs +24 -0
  54. package/dist/templates/arch-modular/nestjs/src/modules/users/users.module.ts.hbs +10 -0
  55. package/dist/templates/arch-modular/nestjs/src/modules/users/users.service.ts.hbs +60 -0
  56. package/dist/templates/arch-modular/nestjs/src/shared/constants.ts.hbs +1 -0
  57. package/dist/templates/arch-modular/nestjs/tests/health.spec.ts.hbs +16 -0
  58. package/dist/templates/arch-mvc/express/src/controllers/health.controller.hbs +7 -0
  59. package/dist/templates/arch-mvc/express/src/controllers/users.controller.hbs +10 -0
  60. package/dist/templates/arch-mvc/express/src/index.hbs +60 -0
  61. package/dist/templates/arch-mvc/express/src/models/user.model.hbs +7 -0
  62. package/dist/templates/arch-mvc/express/src/services/users.service.hbs +39 -0
  63. package/dist/templates/arch-mvc/fastify/src/controllers/users.controller.hbs +9 -0
  64. package/dist/templates/arch-mvc/fastify/src/index.hbs +53 -0
  65. package/dist/templates/arch-mvc/fastify/src/models/user.model.hbs +7 -0
  66. package/dist/templates/arch-mvc/fastify/src/services/users.service.hbs +39 -0
  67. package/dist/templates/arch-mvc/nestjs/src/app.module.ts.hbs +44 -0
  68. package/dist/templates/arch-mvc/nestjs/src/config/config.module.ts.hbs +4 -0
  69. package/dist/templates/arch-mvc/nestjs/src/controllers/health.controller.ts.hbs +11 -0
  70. package/dist/templates/arch-mvc/nestjs/src/controllers/users.controller.ts.hbs +22 -0
  71. package/dist/templates/arch-mvc/nestjs/src/infra/prisma/prisma.module.ts.hbs +6 -0
  72. package/dist/templates/arch-mvc/nestjs/src/infra/prisma/prisma.service.ts.hbs +8 -0
  73. package/dist/templates/arch-mvc/nestjs/src/main.ts.hbs +21 -0
  74. package/dist/templates/arch-mvc/nestjs/src/models/user.model.ts.hbs +7 -0
  75. package/dist/templates/arch-mvc/nestjs/src/services/users.service.ts.hbs +61 -0
  76. package/dist/templates/arch-mvc/nestjs/tests/health.spec.ts.hbs +17 -0
  77. package/dist/templates/base-express/.env.example.hbs +21 -0
  78. package/dist/templates/base-express/.gitignore.hbs +6 -0
  79. package/dist/templates/base-express/README.md.hbs +10 -0
  80. package/dist/templates/base-express/docker/Dockerfile.hbs +21 -0
  81. package/dist/templates/base-express/docker/docker-compose.yml.hbs +61 -0
  82. package/dist/templates/base-express/drizzle/drizzle.config.hbs +10 -0
  83. package/dist/templates/base-express/github-actions/ci.yml.hbs +40 -0
  84. package/dist/templates/base-express/package.json.hbs +54 -0
  85. package/dist/templates/base-express/prisma/schema.prisma.hbs +16 -0
  86. package/dist/templates/base-express/tests/health.test.hbs +8 -0
  87. package/dist/templates/base-express/tsconfig.json.hbs +13 -0
  88. package/dist/templates/base-fastify/.env.example.hbs +21 -0
  89. package/dist/templates/base-fastify/.gitignore.hbs +6 -0
  90. package/dist/templates/base-fastify/README.md.hbs +10 -0
  91. package/dist/templates/base-fastify/docker/Dockerfile.hbs +21 -0
  92. package/dist/templates/base-fastify/docker/docker-compose.yml.hbs +61 -0
  93. package/dist/templates/base-fastify/drizzle/drizzle.config.hbs +10 -0
  94. package/dist/templates/base-fastify/github-actions/ci.yml.hbs +40 -0
  95. package/dist/templates/base-fastify/package.json.hbs +50 -0
  96. package/dist/templates/base-fastify/prisma/schema.prisma.hbs +16 -0
  97. package/dist/templates/base-fastify/tests/health.test.hbs +8 -0
  98. package/dist/templates/base-fastify/tsconfig.json.hbs +13 -0
  99. package/dist/templates/base-nestjs/.env.example.hbs +24 -0
  100. package/dist/templates/base-nestjs/.gitignore.hbs +10 -0
  101. package/dist/templates/base-nestjs/README.md.hbs +46 -0
  102. package/dist/templates/base-nestjs/docker/Dockerfile.hbs +21 -0
  103. package/dist/templates/base-nestjs/docker/docker-compose.yml.hbs +69 -0
  104. package/dist/templates/base-nestjs/drizzle/drizzle.config.ts.hbs +10 -0
  105. package/dist/templates/base-nestjs/github-actions/ci.yml.hbs +38 -0
  106. package/dist/templates/base-nestjs/nest-cli.json.hbs +8 -0
  107. package/dist/templates/base-nestjs/package.json.hbs +65 -0
  108. package/dist/templates/base-nestjs/prisma/schema.prisma.hbs +16 -0
  109. package/dist/templates/base-nestjs/tsconfig.json.hbs +19 -0
  110. package/dist/templates/shared-express/src/infra/auth/clerk.middleware.hbs +12 -0
  111. package/dist/templates/shared-express/src/infra/auth/jwt.middleware.hbs +18 -0
  112. package/dist/templates/shared-express/src/infra/drizzle/client.hbs +18 -0
  113. package/dist/templates/shared-express/src/infra/drizzle/schema.hbs +22 -0
  114. package/dist/templates/shared-express/src/infra/prisma/client.hbs +15 -0
  115. package/dist/templates/shared-express/src/infra/sequelize/models/user.model.ts.hbs +22 -0
  116. package/dist/templates/shared-express/src/infra/sequelize/sequelize.ts.hbs +16 -0
  117. package/dist/templates/shared-express/src/infra/swagger/setup.hbs +19 -0
  118. package/dist/templates/shared-express/src/infra/typeorm/data-source.hbs +17 -0
  119. package/dist/templates/shared-express/src/infra/typeorm/entities/user.entity.hbs +25 -0
  120. package/dist/templates/shared-fastify/src/infra/auth/clerk.middleware.hbs +16 -0
  121. package/dist/templates/shared-fastify/src/infra/auth/jwt.middleware.hbs +14 -0
  122. package/dist/templates/shared-fastify/src/infra/drizzle/client.hbs +18 -0
  123. package/dist/templates/shared-fastify/src/infra/drizzle/schema.hbs +22 -0
  124. package/dist/templates/shared-fastify/src/infra/prisma/client.hbs +15 -0
  125. package/dist/templates/shared-fastify/src/infra/sequelize/models/user.model.ts.hbs +22 -0
  126. package/dist/templates/shared-fastify/src/infra/sequelize/sequelize.ts.hbs +16 -0
  127. package/dist/templates/shared-fastify/src/infra/swagger/setup.hbs +16 -0
  128. package/dist/templates/shared-fastify/src/infra/typeorm/data-source.hbs +17 -0
  129. package/dist/templates/shared-fastify/src/infra/typeorm/entities/user.entity.hbs +25 -0
  130. package/dist/templates/shared-nestjs/src/infra/auth/clerk/clerk-auth.guard.ts.hbs +25 -0
  131. package/dist/templates/shared-nestjs/src/infra/auth/jwt/jwt-auth.guard.ts.hbs +5 -0
  132. package/dist/templates/shared-nestjs/src/infra/auth/jwt/jwt.module.ts.hbs +17 -0
  133. package/dist/templates/shared-nestjs/src/infra/auth/jwt/jwt.strategy.ts.hbs +18 -0
  134. package/dist/templates/shared-nestjs/src/infra/drizzle/drizzle.module.ts.hbs +9 -0
  135. package/dist/templates/shared-nestjs/src/infra/drizzle/drizzle.service.ts.hbs +31 -0
  136. package/dist/templates/shared-nestjs/src/infra/drizzle/schema.ts.hbs +22 -0
  137. package/dist/templates/shared-nestjs/src/infra/sequelize/models/user.model.ts.hbs +22 -0
  138. package/dist/templates/shared-nestjs/src/infra/sequelize/sequelize.module.ts.hbs +18 -0
  139. package/dist/templates/shared-nestjs/src/infra/typeorm/entities/user.entity.ts.hbs +25 -0
  140. package/dist/templates/shared-nestjs/src/infra/typeorm/typeorm.module.ts.hbs +18 -0
  141. package/dist/templates/shared-nestjs/src/infrastructure/drizzle/drizzle.module.ts.hbs +9 -0
  142. package/dist/templates/shared-nestjs/src/infrastructure/drizzle/drizzle.service.ts.hbs +31 -0
  143. package/dist/templates/shared-nestjs/src/infrastructure/drizzle/schema.ts.hbs +22 -0
  144. package/dist/templates/shared-nestjs/src/infrastructure/sequelize/models/user.model.ts.hbs +22 -0
  145. package/dist/templates/shared-nestjs/src/infrastructure/sequelize/sequelize.module.ts.hbs +18 -0
  146. package/dist/templates/shared-nestjs/src/infrastructure/typeorm/entities/user.entity.ts.hbs +25 -0
  147. package/dist/templates/shared-nestjs/src/infrastructure/typeorm/typeorm.module.ts.hbs +18 -0
  148. package/dist/validate.d.ts +2 -0
  149. package/dist/validate.js +41 -0
  150. package/dist/zip.d.ts +2 -0
  151. package/dist/zip.js +20 -0
  152. package/package.json +37 -0
@@ -0,0 +1,8 @@
1
+ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
+ import { PrismaClient } from '@prisma/client';
3
+
4
+ @Injectable()
5
+ export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
6
+ async onModuleInit() { await this.$connect(); }
7
+ async onModuleDestroy() { await this.$disconnect(); }
8
+ }
@@ -0,0 +1,21 @@
1
+ {{#if useReflectMetadata}}import 'reflect-metadata';
2
+ {{/if}}import { NestFactory } from '@nestjs/core';
3
+ import { AppModule } from './app.module';
4
+ {{#if swagger}}
5
+ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
6
+ {{/if}}
7
+
8
+ async function bootstrap() {
9
+ const app = await NestFactory.create(AppModule);
10
+ app.setGlobalPrefix('api');
11
+ {{#if swagger}}
12
+ const config = new DocumentBuilder()
13
+ .setTitle('{{projectSlug}}')
14
+ .setDescription('{{description}}')
15
+ .setVersion('1.0')
16
+ .build();
17
+ SwaggerModule.setup('docs', app, SwaggerModule.createDocument(app, config));
18
+ {{/if}}
19
+ await app.listen(process.env.PORT ?? 3000);
20
+ }
21
+ bootstrap();
@@ -0,0 +1,7 @@
1
+ export class UserModel {
2
+ constructor(
3
+ public readonly id: string,
4
+ public readonly email: string,
5
+ public readonly name: string,
6
+ ) {}
7
+ }
@@ -0,0 +1,61 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { UserModel } from '../models/user.model';
3
+ {{#if usePrisma}}
4
+ import { PrismaService } from '../infra/prisma/prisma.service';
5
+ {{/if}}
6
+ {{#if useTypeorm}}
7
+ import { InjectRepository } from '@nestjs/typeorm';
8
+ import { Repository } from 'typeorm';
9
+ import { UserEntity } from '../infra/typeorm/entities/user.entity';
10
+ {{/if}}
11
+ {{#if useDrizzle}}
12
+ import { DrizzleService } from '../infra/drizzle/drizzle.service';
13
+ import { users } from '../infra/drizzle/schema';
14
+ {{/if}}
15
+ {{#if useSequelize}}
16
+ import { InjectModel } from '@nestjs/sequelize';
17
+ import { User } from '../infra/sequelize/models/user.model';
18
+ {{/if}}
19
+
20
+ @Injectable()
21
+ export class UsersService {
22
+ {{#if usePrisma}}
23
+ constructor(private readonly prisma: PrismaService) {}
24
+
25
+ findAll() {
26
+ return this.prisma.user.findMany();
27
+ }
28
+ {{/if}}
29
+ {{#if useTypeorm}}
30
+ constructor(
31
+ @InjectRepository(UserEntity)
32
+ private readonly repo: Repository<UserEntity>,
33
+ ) {}
34
+
35
+ findAll() {
36
+ return this.repo.find();
37
+ }
38
+ {{/if}}
39
+ {{#if useDrizzle}}
40
+ constructor(private readonly drizzle: DrizzleService) {}
41
+
42
+ findAll() {
43
+ return this.drizzle.db.select().from(users);
44
+ }
45
+ {{/if}}
46
+ {{#if useSequelize}}
47
+ constructor(
48
+ @InjectModel(User)
49
+ private readonly userModel: typeof User,
50
+ ) {}
51
+
52
+ findAll() {
53
+ return this.userModel.findAll();
54
+ }
55
+ {{/if}}
56
+ {{#unless hasRealOrm}}
57
+ findAll(): UserModel[] {
58
+ return [new UserModel('1', 'user@example.com', 'Demo User')];
59
+ }
60
+ {{/unless}}
61
+ }
@@ -0,0 +1,17 @@
1
+ import { Test } from '@nestjs/testing';
2
+ import { HealthController } from '../src/controllers/health.controller';
3
+
4
+ describe('HealthController', () => {
5
+ it('should return ok status', async () => {
6
+ const module = await Test.createTestingModule({
7
+ controllers: [HealthController],
8
+ }).compile();
9
+
10
+ const controller = module.get(HealthController);
11
+ const result = controller.check();
12
+
13
+ expect(result.status).toBe('ok');
14
+ expect(result.service).toBe('{{projectSlug}}');
15
+ expect(result.architecture).toBe('mvc');
16
+ });
17
+ });
@@ -0,0 +1,21 @@
1
+ NODE_ENV=development
2
+ PORT=3000
3
+ {{#if usePostgres}}
4
+ DATABASE_URL=postgresql://postgres:postgres@localhost:5432/{{projectSlug}}
5
+ {{/if}}
6
+ {{#if useMysql}}
7
+ DATABASE_URL=mysql://root:root@localhost:3306/{{projectSlug}}
8
+ {{/if}}
9
+ {{#if useMongodb}}
10
+ DATABASE_URL=mongodb://localhost:27017/{{projectSlug}}
11
+ {{/if}}
12
+ {{#if hasRedis}}
13
+ REDIS_URL=redis://localhost:6379
14
+ {{/if}}
15
+ {{#if useJwt}}
16
+ JWT_SECRET=change-me-in-production
17
+ JWT_EXPIRES_IN=7d
18
+ {{/if}}
19
+ {{#if useClerk}}
20
+ CLERK_SECRET_KEY=sk_test_xxx
21
+ {{/if}}
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ dist
3
+ .env
4
+ .env.local
5
+ *.log
6
+ .DS_Store
@@ -0,0 +1,10 @@
1
+ # {{projectSlug}}
2
+
3
+ {{description}}
4
+
5
+ API Express gerada pelo Node Initializr.
6
+
7
+ ```bash
8
+ {{pmInstallDev}}
9
+ {{pmRunDev}}
10
+ ```
@@ -0,0 +1,21 @@
1
+ FROM node:{{nodeVersion}}-alpine
2
+ WORKDIR /app
3
+ ENV NODE_ENV=production
4
+
5
+ {{#if isPnpm}}RUN corepack enable
6
+ COPY package.json ./
7
+ RUN pnpm install --prod
8
+ {{else}}{{#if isYarn}}COPY package.json yarn.lock* ./
9
+ RUN yarn install --frozen-lockfile --production
10
+ {{else}}COPY package*.json ./
11
+ RUN npm ci --omit=dev
12
+ {{/if}}{{/if}}COPY . .
13
+ {{#if usePrisma}}
14
+ RUN npx prisma generate
15
+ {{/if}}
16
+ {{#if isTypescript}}
17
+ RUN {{pmRunBuild}}
18
+ {{/if}}
19
+
20
+ EXPOSE 3000
21
+ CMD ["node", "{{#if isTypescript}}dist/index.js{{else}}src/index.js{{/if}}"]
@@ -0,0 +1,61 @@
1
+ services:
2
+ app:
3
+ build: ..
4
+ ports:
5
+ - "3000:3000"
6
+ env_file:
7
+ - ../.env
8
+ depends_on:
9
+ {{#if hasDatabase}}
10
+ db:
11
+ condition: service_healthy
12
+ {{/if}}
13
+ {{#if hasRedis}}
14
+ redis:
15
+ condition: service_started
16
+ {{/if}}
17
+
18
+ {{#if usePostgres}}
19
+ db:
20
+ image: postgres:16-alpine
21
+ environment:
22
+ POSTGRES_USER: postgres
23
+ POSTGRES_PASSWORD: postgres
24
+ POSTGRES_DB: {{projectSlug}}
25
+ ports:
26
+ - "5432:5432"
27
+ healthcheck:
28
+ test: ["CMD-SHELL", "pg_isready -U postgres"]
29
+ interval: 5s
30
+ timeout: 5s
31
+ retries: 5
32
+ {{/if}}
33
+
34
+ {{#if useMysql}}
35
+ db:
36
+ image: mysql:8
37
+ environment:
38
+ MYSQL_ROOT_PASSWORD: root
39
+ MYSQL_DATABASE: {{projectSlug}}
40
+ ports:
41
+ - "3306:3306"
42
+ healthcheck:
43
+ test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
44
+ interval: 5s
45
+ timeout: 5s
46
+ retries: 5
47
+ {{/if}}
48
+
49
+ {{#if useMongodb}}
50
+ db:
51
+ image: mongo:7
52
+ ports:
53
+ - "27017:27017"
54
+ {{/if}}
55
+
56
+ {{#if hasRedis}}
57
+ redis:
58
+ image: redis:7-alpine
59
+ ports:
60
+ - "6379:6379"
61
+ {{/if}}
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+
3
+ export default defineConfig({
4
+ schema: './src/infra/drizzle/schema.{{ext}}',
5
+ out: './drizzle/migrations',
6
+ dialect: '{{#if usePostgres}}postgresql{{/if}}{{#if useMysql}}mysql{{/if}}',
7
+ dbCredentials: {
8
+ url: process.env.DATABASE_URL!,
9
+ },
10
+ });
@@ -0,0 +1,40 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ {{#if isPnpm}} - uses: pnpm/action-setup@v4
15
+ with:
16
+ version: 9
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '{{nodeVersion}}'
20
+ cache: pnpm
21
+ - run: {{pmInstall}}
22
+ {{else}}{{#if isYarn}} - uses: actions/setup-node@v4
23
+ with:
24
+ node-version: '{{nodeVersion}}'
25
+ cache: yarn
26
+ - run: {{pmInstall}}
27
+ {{else}} - uses: actions/setup-node@v4
28
+ with:
29
+ node-version: '{{nodeVersion}}'
30
+ cache: npm
31
+ - run: {{pmInstall}}
32
+ {{/if}}{{/if}}{{#if usePrisma}}
33
+ - run: npx prisma generate
34
+ {{/if}}
35
+ {{#if isTypescript}}
36
+ - run: {{pmRunBuild}}
37
+ {{/if}}
38
+ {{#if jest}}
39
+ - run: {{pmRunTest}}
40
+ {{/if}}
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "{{projectSlug}}",
3
+ "version": "0.0.1",
4
+ "description": "{{description}}",
5
+ "private": true,{{#if isPnpm}}
6
+ "packageManager": "pnpm@9.15.0",{{/if}}{{#if isYarn}}
7
+ "packageManager": "yarn@1.22.22",{{/if}}
8
+ "type": "module",
9
+ "scripts": {
10
+ "start": "node {{#if isTypescript}}dist/index.js{{else}}src/index.js{{/if}}",
11
+ "dev": "node --watch src/index.{{ext}}"{{#if isTypescript}},
12
+ "build": "tsc"{{/if}}{{#if usePrisma}},
13
+ "db:generate": "prisma generate",
14
+ "db:migrate": "prisma migrate dev"{{/if}}{{#if useDrizzle}},
15
+ "db:generate": "drizzle-kit generate",
16
+ "db:migrate": "drizzle-kit migrate"{{/if}}{{#if jest}},
17
+ "test": "node --test test/**/*.test.{{ext}}"{{/if}}
18
+ },
19
+ "dependencies": {
20
+ "express": "^4.21.0",
21
+ "cors": "^2.8.5",
22
+ "helmet": "^8.0.0",
23
+ "dotenv": "^16.4.0"{{#if usePrisma}},
24
+ "@prisma/client": "^6.0.0"{{/if}}{{#if useTypeorm}},
25
+ "typeorm": "^0.3.20",
26
+ "reflect-metadata": "^0.2.2",
27
+ "{{dbDriver}}": "latest"{{/if}}{{#if useDrizzle}},
28
+ "drizzle-orm": "^0.38.0",
29
+ "{{dbDriver}}": "latest"{{/if}}{{#if useSequelize}},
30
+ "sequelize": "^6.37.0",
31
+ "sequelize-typescript": "^2.1.6",
32
+ "reflect-metadata": "^0.2.2",
33
+ "{{dbDriver}}": "latest"{{/if}}{{#if useJwt}},
34
+ "jsonwebtoken": "^9.0.0",
35
+ "bcrypt": "^5.1.1"{{/if}}{{#if useClerk}},
36
+ "@clerk/express": "^1.0.0"{{/if}}{{#if swagger}},
37
+ "swagger-ui-express": "^5.0.0",
38
+ "swagger-jsdoc": "^6.2.8"{{/if}}{{#if hasRedis}},
39
+ "ioredis": "^5.4.0"{{/if}}
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.0.0"{{#if isTypescript}},
43
+ "typescript": "^5.7.0",
44
+ "@types/express": "^5.0.0",
45
+ "@types/cors": "^2.8.0"{{/if}}{{#if useJwt}},
46
+ "@types/jsonwebtoken": "^9.0.0"{{/if}}{{#if usePrisma}},
47
+ "prisma": "^6.0.0"{{/if}}{{#if useDrizzle}},
48
+ "drizzle-kit": "^0.30.0"{{/if}}{{#if swagger}},
49
+ "@types/swagger-ui-express": "^4.1.0"{{/if}}
50
+ },
51
+ "engines": {
52
+ "node": ">={{nodeVersion}}.0.0"
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "{{#if usePostgres}}postgresql{{/if}}{{#if useMysql}}mysql{{/if}}{{#if useMongodb}}mongodb{{/if}}"
7
+ url = env("DATABASE_URL")
8
+ }
9
+
10
+ model User {
11
+ id String @id @default(cuid())
12
+ email String @unique
13
+ name String?
14
+ createdAt DateTime @default(now())
15
+ updatedAt DateTime @updatedAt
16
+ }
@@ -0,0 +1,8 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
4
+ describe('{{projectSlug}}', () => {
5
+ it('should have correct project name', () => {
6
+ assert.strictEqual('{{projectSlug}}', '{{projectSlug}}');
7
+ });
8
+ });
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["src/**/*"]
13
+ }
@@ -0,0 +1,21 @@
1
+ NODE_ENV=development
2
+ PORT=3000
3
+ {{#if usePostgres}}
4
+ DATABASE_URL=postgresql://postgres:postgres@localhost:5432/{{projectSlug}}
5
+ {{/if}}
6
+ {{#if useMysql}}
7
+ DATABASE_URL=mysql://root:root@localhost:3306/{{projectSlug}}
8
+ {{/if}}
9
+ {{#if useMongodb}}
10
+ DATABASE_URL=mongodb://localhost:27017/{{projectSlug}}
11
+ {{/if}}
12
+ {{#if hasRedis}}
13
+ REDIS_URL=redis://localhost:6379
14
+ {{/if}}
15
+ {{#if useJwt}}
16
+ JWT_SECRET=change-me-in-production
17
+ JWT_EXPIRES_IN=7d
18
+ {{/if}}
19
+ {{#if useClerk}}
20
+ CLERK_SECRET_KEY=sk_test_xxx
21
+ {{/if}}
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ dist
3
+ .env
4
+ .env.local
5
+ *.log
6
+ .DS_Store
@@ -0,0 +1,10 @@
1
+ # {{projectSlug}}
2
+
3
+ {{description}}
4
+
5
+ API Fastify gerada pelo Node Initializr.
6
+
7
+ ```bash
8
+ {{pmInstallDev}}
9
+ {{pmRunDev}}
10
+ ```
@@ -0,0 +1,21 @@
1
+ FROM node:{{nodeVersion}}-alpine
2
+ WORKDIR /app
3
+ ENV NODE_ENV=production
4
+
5
+ {{#if isPnpm}}RUN corepack enable
6
+ COPY package.json ./
7
+ RUN pnpm install --prod
8
+ {{else}}{{#if isYarn}}COPY package.json yarn.lock* ./
9
+ RUN yarn install --frozen-lockfile --production
10
+ {{else}}COPY package*.json ./
11
+ RUN npm ci --omit=dev
12
+ {{/if}}{{/if}}COPY . .
13
+ {{#if usePrisma}}
14
+ RUN npx prisma generate
15
+ {{/if}}
16
+ {{#if isTypescript}}
17
+ RUN {{pmRunBuild}}
18
+ {{/if}}
19
+
20
+ EXPOSE 3000
21
+ CMD ["node", "{{#if isTypescript}}dist/index.js{{else}}src/index.js{{/if}}"]
@@ -0,0 +1,61 @@
1
+ services:
2
+ app:
3
+ build: ..
4
+ ports:
5
+ - "3000:3000"
6
+ env_file:
7
+ - ../.env
8
+ depends_on:
9
+ {{#if hasDatabase}}
10
+ db:
11
+ condition: service_healthy
12
+ {{/if}}
13
+ {{#if hasRedis}}
14
+ redis:
15
+ condition: service_started
16
+ {{/if}}
17
+
18
+ {{#if usePostgres}}
19
+ db:
20
+ image: postgres:16-alpine
21
+ environment:
22
+ POSTGRES_USER: postgres
23
+ POSTGRES_PASSWORD: postgres
24
+ POSTGRES_DB: {{projectSlug}}
25
+ ports:
26
+ - "5432:5432"
27
+ healthcheck:
28
+ test: ["CMD-SHELL", "pg_isready -U postgres"]
29
+ interval: 5s
30
+ timeout: 5s
31
+ retries: 5
32
+ {{/if}}
33
+
34
+ {{#if useMysql}}
35
+ db:
36
+ image: mysql:8
37
+ environment:
38
+ MYSQL_ROOT_PASSWORD: root
39
+ MYSQL_DATABASE: {{projectSlug}}
40
+ ports:
41
+ - "3306:3306"
42
+ healthcheck:
43
+ test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
44
+ interval: 5s
45
+ timeout: 5s
46
+ retries: 5
47
+ {{/if}}
48
+
49
+ {{#if useMongodb}}
50
+ db:
51
+ image: mongo:7
52
+ ports:
53
+ - "27017:27017"
54
+ {{/if}}
55
+
56
+ {{#if hasRedis}}
57
+ redis:
58
+ image: redis:7-alpine
59
+ ports:
60
+ - "6379:6379"
61
+ {{/if}}
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+
3
+ export default defineConfig({
4
+ schema: './src/infra/drizzle/schema.{{ext}}',
5
+ out: './drizzle/migrations',
6
+ dialect: '{{#if usePostgres}}postgresql{{/if}}{{#if useMysql}}mysql{{/if}}',
7
+ dbCredentials: {
8
+ url: process.env.DATABASE_URL!,
9
+ },
10
+ });
@@ -0,0 +1,40 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ {{#if isPnpm}} - uses: pnpm/action-setup@v4
15
+ with:
16
+ version: 9
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '{{nodeVersion}}'
20
+ cache: pnpm
21
+ - run: {{pmInstall}}
22
+ {{else}}{{#if isYarn}} - uses: actions/setup-node@v4
23
+ with:
24
+ node-version: '{{nodeVersion}}'
25
+ cache: yarn
26
+ - run: {{pmInstall}}
27
+ {{else}} - uses: actions/setup-node@v4
28
+ with:
29
+ node-version: '{{nodeVersion}}'
30
+ cache: npm
31
+ - run: {{pmInstall}}
32
+ {{/if}}{{/if}}{{#if usePrisma}}
33
+ - run: npx prisma generate
34
+ {{/if}}
35
+ {{#if isTypescript}}
36
+ - run: {{pmRunBuild}}
37
+ {{/if}}
38
+ {{#if jest}}
39
+ - run: {{pmRunTest}}
40
+ {{/if}}
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "{{projectSlug}}",
3
+ "version": "0.0.1",
4
+ "description": "{{description}}",
5
+ "private": true,{{#if isPnpm}}
6
+ "packageManager": "pnpm@9.15.0",{{/if}}{{#if isYarn}}
7
+ "packageManager": "yarn@1.22.22",{{/if}}
8
+ "type": "module",
9
+ "scripts": {
10
+ "start": "node {{#if isTypescript}}dist/index.js{{else}}src/index.js{{/if}}",
11
+ "dev": "node --watch src/index.{{ext}}"{{#if isTypescript}},
12
+ "build": "tsc"{{/if}}{{#if usePrisma}},
13
+ "db:generate": "prisma generate",
14
+ "db:migrate": "prisma migrate dev"{{/if}}{{#if useDrizzle}},
15
+ "db:generate": "drizzle-kit generate",
16
+ "db:migrate": "drizzle-kit migrate"{{/if}}{{#if jest}},
17
+ "test": "node --test test/**/*.test.{{ext}}"{{/if}}
18
+ },
19
+ "dependencies": {
20
+ "fastify": "^5.0.0",
21
+ "@fastify/cors": "^10.0.0",
22
+ "@fastify/helmet": "^12.0.0",
23
+ "dotenv": "^16.4.0"{{#if usePrisma}},
24
+ "@prisma/client": "^6.0.0"{{/if}}{{#if useTypeorm}},
25
+ "typeorm": "^0.3.20",
26
+ "reflect-metadata": "^0.2.2",
27
+ "{{dbDriver}}": "latest"{{/if}}{{#if useDrizzle}},
28
+ "drizzle-orm": "^0.38.0",
29
+ "{{dbDriver}}": "latest"{{/if}}{{#if useSequelize}},
30
+ "sequelize": "^6.37.0",
31
+ "sequelize-typescript": "^2.1.6",
32
+ "reflect-metadata": "^0.2.2",
33
+ "{{dbDriver}}": "latest"{{/if}}{{#if useJwt}},
34
+ "jsonwebtoken": "^9.0.0"{{/if}}{{#if useClerk}},
35
+ "@clerk/backend": "^1.0.0"{{/if}}{{#if swagger}},
36
+ "@fastify/swagger": "^9.0.0",
37
+ "@fastify/swagger-ui": "^5.0.0"{{/if}}{{#if hasRedis}},
38
+ "ioredis": "^5.4.0"{{/if}}
39
+ },
40
+ "devDependencies": {
41
+ {{#if isTypescript}}"typescript": "^5.7.0",{{/if}}{{#if usePrisma}}
42
+ "prisma": "^6.0.0",{{/if}}{{#if useDrizzle}}
43
+ "drizzle-kit": "^0.30.0",{{/if}}
44
+ "@types/node": "^22.0.0"{{#if useJwt}},
45
+ "@types/jsonwebtoken": "^9.0.0"{{/if}}
46
+ },
47
+ "engines": {
48
+ "node": ">={{nodeVersion}}.0.0"
49
+ }
50
+ }
@@ -0,0 +1,16 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ }
4
+
5
+ datasource db {
6
+ provider = "{{#if usePostgres}}postgresql{{/if}}{{#if useMysql}}mysql{{/if}}{{#if useMongodb}}mongodb{{/if}}"
7
+ url = env("DATABASE_URL")
8
+ }
9
+
10
+ model User {
11
+ id String @id @default(cuid())
12
+ email String @unique
13
+ name String?
14
+ createdAt DateTime @default(now())
15
+ updatedAt DateTime @updatedAt
16
+ }
@@ -0,0 +1,8 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
4
+ describe('{{projectSlug}}', () => {
5
+ it('should have correct project name', () => {
6
+ assert.strictEqual('{{projectSlug}}', '{{projectSlug}}');
7
+ });
8
+ });
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["src/**/*"]
13
+ }