kybernus 3.0.1 → 3.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 (106) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/templates/java-spring/clean/.gitignore.hbs +72 -0
  4. package/templates/java-spring/clean/docker-compose.yml.hbs +6 -3
  5. package/templates/java-spring/clean/src/main/java/{{packagePath}}/application/usecase/PaymentUseCase.java.hbs +21 -17
  6. package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/persistence/entity/UserEntity.java.hbs +52 -0
  7. package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/persistence/repository/JpaUserRepository.java.hbs +12 -0
  8. package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/security/JwtAuthenticationFilter.java.hbs +64 -0
  9. package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/security/SecurityConfig.java.hbs +36 -0
  10. package/templates/java-spring/clean/src/main/java/{{packagePath}}/infrastructure/stripe/StripeGateway.java.hbs +63 -0
  11. package/templates/java-spring/clean/src/main/resources/application.properties.hbs +6 -7
  12. package/templates/java-spring/hexagonal/.gitignore.hbs +72 -0
  13. package/templates/java-spring/hexagonal/docker-compose.yml.hbs +6 -3
  14. package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/adapters/outbound/security/JwtFilter.java.hbs +71 -0
  15. package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/adapters/outbound/security/SecurityConfig.java.hbs +35 -0
  16. package/templates/java-spring/hexagonal/src/main/java/{{packagePath}}/core/service/PaymentService.java.hbs +3 -3
  17. package/templates/java-spring/hexagonal/src/main/resources/application.properties.hbs +4 -4
  18. package/templates/java-spring/mvc/.gitignore.hbs +72 -0
  19. package/templates/java-spring/mvc/docker-compose.yml.hbs +6 -3
  20. package/templates/java-spring/mvc/src/main/java/{{packagePath}}/config/SecurityConfig.java.hbs +13 -12
  21. package/templates/java-spring/mvc/src/main/java/{{packagePath}}/controller/AuthController.java.hbs +9 -8
  22. package/templates/java-spring/mvc/src/main/java/{{packagePath}}/controller/PaymentsController.java.hbs +5 -6
  23. package/templates/java-spring/mvc/src/main/java/{{packagePath}}/service/StripeService.java.hbs +3 -3
  24. package/templates/java-spring/mvc/src/main/resources/application.yml.hbs +29 -26
  25. package/templates/nestjs/clean/.gitignore.hbs +42 -0
  26. package/templates/nestjs/clean/Dockerfile.hbs +6 -3
  27. package/templates/nestjs/clean/docker-compose.yml.hbs +1 -11
  28. package/templates/nestjs/clean/src/app.module.ts.hbs +2 -1
  29. package/templates/nestjs/clean/src/application/payment.service.ts.hbs +72 -72
  30. package/templates/nestjs/clean/src/domain/entities/user.entity.ts.hbs +2 -2
  31. package/templates/nestjs/clean/src/domain/repositories/user.repository.ts.hbs +2 -2
  32. package/templates/nestjs/clean/src/infrastructure/database/repositories/prisma.user.repository.ts.hbs +18 -18
  33. package/templates/nestjs/clean/src/infrastructure/http/health.controller.ts.hbs +9 -0
  34. package/templates/nestjs/clean/src/main.ts.hbs +1 -4
  35. package/templates/nestjs/clean/src/payment.module.ts.hbs +12 -12
  36. package/templates/nestjs/hexagonal/.gitignore.hbs +42 -0
  37. package/templates/nestjs/hexagonal/Dockerfile.hbs +6 -3
  38. package/templates/nestjs/hexagonal/docker-compose.yml.hbs +1 -11
  39. package/templates/nestjs/hexagonal/src/adapters/inbound/health.controller.ts.hbs +9 -0
  40. package/templates/nestjs/hexagonal/src/app.module.ts.hbs +2 -1
  41. package/templates/nestjs/hexagonal/src/core/domain/user.entity.ts.hbs +6 -6
  42. package/templates/nestjs/hexagonal/src/core/ports/ports.ts.hbs +4 -4
  43. package/templates/nestjs/hexagonal/src/main.ts.hbs +1 -4
  44. package/templates/nestjs/mvc/.gitignore.hbs +42 -0
  45. package/templates/nestjs/mvc/Dockerfile.hbs +6 -3
  46. package/templates/nestjs/mvc/docker-compose.yml.hbs +1 -11
  47. package/templates/nestjs/mvc/src/auth/auth.controller.ts.hbs +11 -1
  48. package/templates/nestjs/mvc/src/auth/auth.service.ts.hbs +3 -1
  49. package/templates/nestjs/mvc/src/controllers/health.controller.ts.hbs +6 -6
  50. package/templates/nestjs/mvc/src/main.ts.hbs +1 -4
  51. package/templates/nestjs/mvc/src/models/create-item.dto.ts.hbs +5 -2
  52. package/templates/nestjs/mvc/src/prisma/prisma.service.ts.hbs +1 -0
  53. package/templates/nextjs/mvc/.gitignore.hbs +42 -0
  54. package/templates/nextjs/mvc/Dockerfile.hbs +23 -8
  55. package/templates/nextjs/mvc/docker-compose.yml.hbs +1 -1
  56. package/templates/nodejs-express/clean/.gitignore.hbs +42 -0
  57. package/templates/nodejs-express/clean/Dockerfile.hbs +6 -1
  58. package/templates/nodejs-express/clean/docker-compose.yml.hbs +2 -2
  59. package/templates/nodejs-express/clean/package.json.hbs +69 -69
  60. package/templates/nodejs-express/clean/src/config.ts.hbs +11 -0
  61. package/templates/nodejs-express/clean/src/domain/entities/User.ts.hbs +46 -8
  62. package/templates/nodejs-express/hexagonal/.gitignore.hbs +42 -0
  63. package/templates/nodejs-express/hexagonal/Dockerfile.hbs +1 -1
  64. package/templates/nodejs-express/hexagonal/docker-compose.yml.hbs +2 -2
  65. package/templates/nodejs-express/hexagonal/package.json.hbs +69 -69
  66. package/templates/nodejs-express/hexagonal/src/adapters/inbound/http/PaymentController.ts.hbs +21 -38
  67. package/templates/nodejs-express/hexagonal/src/adapters/outbound/persistence/prisma.ts.hbs +2 -0
  68. package/templates/nodejs-express/hexagonal/src/config.ts.hbs +9 -0
  69. package/templates/nodejs-express/hexagonal/src/core/AuthService.ts.hbs +5 -5
  70. package/templates/nodejs-express/hexagonal/src/core/PaymentService.ts.hbs +7 -22
  71. package/templates/nodejs-express/hexagonal/src/core/domain/entities/User.ts.hbs +24 -4
  72. package/templates/nodejs-express/mvc/.gitignore.hbs +42 -0
  73. package/templates/nodejs-express/mvc/package.json.hbs +67 -67
  74. package/templates/python-fastapi/clean/.gitignore.hbs +76 -0
  75. package/templates/python-fastapi/clean/app/application/services/payment_service.py.hbs +3 -3
  76. package/templates/python-fastapi/clean/app/config.py.hbs +6 -7
  77. package/templates/python-fastapi/clean/app/domain/usecases/login_user.py.hbs +15 -0
  78. package/templates/python-fastapi/clean/app/infrastructure/http/auth_controller.py.hbs +40 -6
  79. package/templates/python-fastapi/clean/app/infrastructure/http/payment_controller.py.hbs +5 -4
  80. package/templates/python-fastapi/clean/app/infrastructure/security/jwt.py.hbs +23 -0
  81. package/templates/python-fastapi/clean/app/main.py.hbs +3 -0
  82. package/templates/python-fastapi/clean/docker-compose.yml.hbs +5 -12
  83. package/templates/python-fastapi/clean/requirements.txt.hbs +3 -0
  84. package/templates/python-fastapi/hexagonal/.gitignore.hbs +76 -0
  85. package/templates/python-fastapi/hexagonal/app/adapters/inbound/http_adapter.py.hbs +6 -9
  86. package/templates/python-fastapi/hexagonal/app/adapters/inbound/payment_http_adapter.py.hbs +4 -3
  87. package/templates/python-fastapi/hexagonal/app/adapters/outbound/stripe_adapter.py.hbs +30 -19
  88. package/templates/python-fastapi/hexagonal/app/config.py.hbs +14 -4
  89. package/templates/python-fastapi/hexagonal/app/core/domain/user.py.hbs +3 -1
  90. package/templates/python-fastapi/hexagonal/app/core/payment_service.py.hbs +28 -18
  91. package/templates/python-fastapi/hexagonal/app/core/ports/__init__.py.hbs +3 -0
  92. package/templates/python-fastapi/hexagonal/app/core/ports/user_repository.py.hbs +15 -0
  93. package/templates/python-fastapi/hexagonal/app/infrastructure/database/session.py.hbs +7 -0
  94. package/templates/python-fastapi/hexagonal/app/infrastructure/database/user_repository.py.hbs +53 -0
  95. package/templates/python-fastapi/hexagonal/app/infrastructure/security/__init__.py.hbs +0 -0
  96. package/templates/python-fastapi/hexagonal/app/infrastructure/security/adapters.py.hbs +23 -0
  97. package/templates/python-fastapi/hexagonal/app/infrastructure/security/jwt.py.hbs +23 -0
  98. package/templates/python-fastapi/hexagonal/docker-compose.yml.hbs +5 -12
  99. package/templates/python-fastapi/hexagonal/requirements.txt.hbs +4 -0
  100. package/templates/python-fastapi/mvc/.gitignore.hbs +76 -0
  101. package/templates/python-fastapi/mvc/app/controllers/payments.py.hbs +3 -17
  102. package/templates/python-fastapi/mvc/app/middleware/security.py.hbs +24 -3
  103. package/templates/python-fastapi/mvc/app/schemas/item.py.hbs +3 -1
  104. package/templates/python-fastapi/mvc/docker-compose.yml.hbs +5 -12
  105. package/templates/python-fastapi/mvc/requirements.txt.hbs +3 -1
  106. package/templates/nodejs-express/hexagonal/src/adapters/outbound/persistence/prisma.ts +0 -5
@@ -0,0 +1,9 @@
1
+ import { Controller, Get } from '@nestjs/common';
2
+
3
+ @Controller('health')
4
+ export class HealthController {
5
+ @Get()
6
+ check() {
7
+ return { status: 'ok' };
8
+ }
9
+ }
@@ -3,10 +3,7 @@ import { AppModule } from './app.module';
3
3
  import { ValidationPipe } from '@nestjs/common';
4
4
 
5
5
  async function bootstrap() {
6
- const app = await NestFactory.create(AppModule, {
7
- // rawBody is required so the Stripe webhook can verify the signature
8
- rawBody: true,
9
- });
6
+ const app = await NestFactory.create(AppModule);
10
7
 
11
8
  app.enableCors();
12
9
  app.setGlobalPrefix('api');
@@ -8,16 +8,16 @@ import { PrismaUserRepository } from './infrastructure/database/prisma.user.repo
8
8
  import { PrismaService } from './infrastructure/database/prisma.service';
9
9
 
10
10
  @Module({
11
- imports: [ConfigModule],
12
- controllers: [PaymentController],
13
- providers: [
14
- PaymentService,
15
- StripeProvider,
16
- PrismaService,
17
- {
18
- provide: UserRepository,
19
- useClass: PrismaUserRepository,
20
- },
21
- ],
11
+ imports: [ConfigModule],
12
+ controllers: [PaymentController],
13
+ providers: [
14
+ PaymentService,
15
+ StripeProvider,
16
+ PrismaService,
17
+ {
18
+ provide: UserRepository,
19
+ useClass: PrismaUserRepository,
20
+ },
21
+ ],
22
22
  })
23
- export class PaymentModule {}
23
+ export class PaymentModule {}
@@ -0,0 +1,42 @@
1
+ # Dependencies
2
+ node_modules/
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # Build outputs
7
+ dist/
8
+ build/
9
+
10
+ # Environment variables
11
+ .env
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+ !.env.example
17
+
18
+ # Logs
19
+ logs/
20
+ *.log
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ pnpm-debug.log*
25
+ lerna-debug.log*
26
+
27
+ # Coverage
28
+ coverage/
29
+ .nyc_output
30
+
31
+ # TypeScript
32
+ *.tsbuildinfo
33
+
34
+ # OS
35
+ .DS_Store
36
+ Thumbs.db
37
+
38
+ # Editor
39
+ .vscode/
40
+ .idea/
41
+ *.swp
42
+ *.swo
@@ -9,7 +9,7 @@ WORKDIR /app
9
9
  COPY package*.json ./
10
10
 
11
11
  # Install dependencies
12
- RUN npm ci --only=production
12
+ RUN npm ci
13
13
 
14
14
  # Copy source code
15
15
  COPY . .
@@ -26,6 +26,9 @@ WORKDIR /app
26
26
  RUN addgroup -g 1001 -S nodejs && \
27
27
  adduser -S nodejs -u 1001
28
28
 
29
+ # Add openssl
30
+ RUN apk add --no-cache openssl
31
+
29
32
  # Copy built application
30
33
  COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
31
34
  COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
@@ -39,7 +42,7 @@ EXPOSE 3000
39
42
 
40
43
  # Health check
41
44
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
42
- CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
45
+ CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
43
46
 
44
47
  # Start application
45
- CMD ["node", "dist/index.js"]
48
+ CMD node dist/main.js
@@ -1,16 +1,6 @@
1
1
  version: '3.8'
2
2
 
3
3
  services:
4
- app:
5
- build: .
6
- container_name: {{kebabCase projectName}}-app
7
- ports:
8
- - "3000:3000"
9
- environment:
10
- - DATABASE_URL=postgresql://postgres:postgres@db:5432/{{snakeCase projectName}}
11
- depends_on:
12
- - db
13
-
14
4
  db:
15
5
  image: postgres:15-alpine
16
6
  container_name: {{kebabCase projectName}}-db
@@ -19,7 +9,7 @@ services:
19
9
  POSTGRES_PASSWORD: postgres
20
10
  POSTGRES_DB: {{snakeCase projectName}}
21
11
  ports:
22
- - "5432:5432"
12
+ - "5434:5432"
23
13
  volumes:
24
14
  - postgres_data:/var/lib/postgresql/data
25
15
  restart: unless-stopped
@@ -0,0 +1,9 @@
1
+ import { Controller, Get } from '@nestjs/common';
2
+
3
+ @Controller('health')
4
+ export class HealthController {
5
+ @Get()
6
+ check() {
7
+ return { status: 'ok' };
8
+ }
9
+ }
@@ -3,6 +3,7 @@ import { ConfigModule } from '@nestjs/config';
3
3
  import { AuthModule } from './auth.module';
4
4
  import { PaymentModule } from './payment.module';
5
5
  import { PrismaService } from './adapters/outbound/persistence/prisma.service';
6
+ import { HealthController } from './adapters/inbound/health.controller';
6
7
 
7
8
  @Module({
8
9
  imports: [
@@ -12,7 +13,7 @@ import { PrismaService } from './adapters/outbound/persistence/prisma.service';
12
13
  AuthModule,
13
14
  PaymentModule,
14
15
  ],
15
- controllers: [],
16
+ controllers: [HealthController],
16
17
  providers: [PrismaService],
17
18
  exports: [PrismaService],
18
19
  })
@@ -1,8 +1,8 @@
1
1
  export class User {
2
- constructor(
3
- public readonly id: string,
4
- public readonly email: string,
5
- public readonly name: string,
6
- public readonly password: string,
7
- ) {}
2
+ constructor(
3
+ public readonly id: string,
4
+ public readonly email: string,
5
+ public readonly name: string,
6
+ public readonly password: string,
7
+ ) {}
8
8
  }
@@ -1,9 +1,9 @@
1
1
  import { User } from '../domain/user.entity';
2
2
 
3
3
  export interface IUserRepositoryPort {
4
- save(user: User): Promise<User>;
5
- }
4
+ save(user: User): Promise<User>;
5
+ }
6
6
 
7
- export interface IAuthPort {
7
+ export interface IAuthPort {
8
8
  register(email: string, name: string, password: string): Promise<User>;
9
- }
9
+ }
@@ -3,10 +3,7 @@ import { AppModule } from './app.module';
3
3
  import { ValidationPipe } from '@nestjs/common';
4
4
 
5
5
  async function bootstrap() {
6
- const app = await NestFactory.create(AppModule, {
7
- // rawBody is required so the Stripe webhook can verify the signature
8
- rawBody: true,
9
- });
6
+ const app = await NestFactory.create(AppModule);
10
7
 
11
8
  app.enableCors();
12
9
  app.setGlobalPrefix('api');
@@ -0,0 +1,42 @@
1
+ # Dependencies
2
+ node_modules/
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # Build outputs
7
+ dist/
8
+ build/
9
+
10
+ # Environment variables
11
+ .env
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+ !.env.example
17
+
18
+ # Logs
19
+ logs/
20
+ *.log
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ pnpm-debug.log*
25
+ lerna-debug.log*
26
+
27
+ # Coverage
28
+ coverage/
29
+ .nyc_output
30
+
31
+ # TypeScript
32
+ *.tsbuildinfo
33
+
34
+ # OS
35
+ .DS_Store
36
+ Thumbs.db
37
+
38
+ # Editor
39
+ .vscode/
40
+ .idea/
41
+ *.swp
42
+ *.swo
@@ -9,7 +9,7 @@ WORKDIR /app
9
9
  COPY package*.json ./
10
10
 
11
11
  # Install dependencies
12
- RUN npm ci --only=production
12
+ RUN npm ci
13
13
 
14
14
  # Copy source code
15
15
  COPY . .
@@ -26,6 +26,9 @@ WORKDIR /app
26
26
  RUN addgroup -g 1001 -S nodejs && \
27
27
  adduser -S nodejs -u 1001
28
28
 
29
+ # Add openssl
30
+ RUN apk add --no-cache openssl
31
+
29
32
  # Copy built application
30
33
  COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
31
34
  COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
@@ -39,7 +42,7 @@ EXPOSE 3000
39
42
 
40
43
  # Health check
41
44
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
42
- CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
45
+ CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
43
46
 
44
47
  # Start application
45
- CMD ["node", "dist/index.js"]
48
+ CMD node dist/main.js
@@ -1,16 +1,6 @@
1
1
  version: '3.8'
2
2
 
3
3
  services:
4
- app:
5
- build: .
6
- container_name: {{kebabCase projectName}}-app
7
- ports:
8
- - "3000:3000"
9
- environment:
10
- - DATABASE_URL=postgresql://postgres:postgres@db:5432/{{snakeCase projectName}}
11
- depends_on:
12
- - db
13
-
14
4
  db:
15
5
  image: postgres:15-alpine
16
6
  container_name: {{kebabCase projectName}}-db
@@ -19,7 +9,7 @@ services:
19
9
  POSTGRES_PASSWORD: postgres
20
10
  POSTGRES_DB: {{snakeCase projectName}}
21
11
  ports:
22
- - "5432:5432"
12
+ - "5434:5432"
23
13
  volumes:
24
14
  - postgres_data:/var/lib/postgresql/data
25
15
  restart: unless-stopped
@@ -1,15 +1,25 @@
1
1
  import { Controller, Post, Body, Get, UseGuards, Request } from '@nestjs/common';
2
2
  import { AuthGuard } from '@nestjs/passport';
3
3
  import { AuthService } from './auth.service';
4
+ import { IsEmail, IsString, MinLength } from 'class-validator';
4
5
 
5
6
  class RegisterDto {
7
+ @IsEmail()
6
8
  email: string;
9
+
10
+ @IsString()
7
11
  name: string;
12
+
13
+ @IsString()
14
+ @MinLength(6)
8
15
  password: string;
9
16
  }
10
17
 
11
18
  class LoginDto {
19
+ @IsEmail()
12
20
  email: string;
21
+
22
+ @IsString()
13
23
  password: string;
14
24
  }
15
25
 
@@ -32,4 +42,4 @@ export class AuthController {
32
42
  async me(@Request() req: any) {
33
43
  return { user: req.user };
34
44
  }
35
- }
45
+ }
@@ -39,7 +39,7 @@ export class AuthService {
39
39
  where: { email },
40
40
  });
41
41
 
42
- if (users || !(await bcrypt.compare(password, user.password))) {
42
+ if (!user || !(await bcrypt.compare(password, user.password))) {
43
43
  throw new UnauthorizedException('Invalid credentials');
44
44
  }
45
45
 
@@ -53,6 +53,8 @@ export class AuthService {
53
53
  select: { id: true, email: true, name: true }
54
54
  });
55
55
 
56
+ if (!user) return null;
57
+
56
58
  return user;
57
59
  }
58
60
  }
@@ -1,9 +1,9 @@
1
1
  import { Controller, Get } from '@nestjs/common';
2
2
 
3
- @Controller()
3
+ @Controller('health')
4
4
  export class HealthController {
5
- @Get('health')
6
- health() {
7
- return { status: 'ok' };
8
- }
9
- }
5
+ @Get()
6
+ check() {
7
+ return { status: 'ok' };
8
+ }
9
+ }
@@ -3,10 +3,7 @@ import { AppModule } from './app.module';
3
3
  import { ValidationPipe } from '@nestjs/common';
4
4
 
5
5
  async function bootstrap() {
6
- const app = await NestFactory.create(AppModule, {
7
- // rawBody is required so that the Stripe webhook can verify the signature
8
- rawBody: true,
9
- });
6
+ const app = await NestFactory.create(AppModule);
10
7
 
11
8
  app.enableCors();
12
9
  app.setGlobalPrefix('api');
@@ -1,4 +1,4 @@
1
- import { IsString, IsOptional } from 'class-validator';
1
+ import { IsString, IsOptional, IsNumber } from 'class-validator';
2
2
 
3
3
  export class CreateItemDto {
4
4
  @IsString()
@@ -7,4 +7,7 @@ export class CreateItemDto {
7
7
  @IsString()
8
8
  @IsOptional()
9
9
  description?: string;
10
- }
10
+
11
+ @IsNumber()
12
+ price: number;
13
+ }
@@ -8,6 +8,7 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
8
8
  }
9
9
 
10
10
  async enableShutdownHooks(app: INestApplication) {
11
+ // @ts-ignore
11
12
  this.$on('beforeExit', async () => {
12
13
  await app.close();
13
14
  });
@@ -0,0 +1,42 @@
1
+ # Dependencies
2
+ node_modules/
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # Build outputs
7
+ dist/
8
+ build/
9
+
10
+ # Environment variables
11
+ .env
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+ !.env.example
17
+
18
+ # Logs
19
+ logs/
20
+ *.log
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ pnpm-debug.log*
25
+ lerna-debug.log*
26
+
27
+ # Coverage
28
+ coverage/
29
+ .nyc_output
30
+
31
+ # TypeScript
32
+ *.tsbuildinfo
33
+
34
+ # OS
35
+ .DS_Store
36
+ Thumbs.db
37
+
38
+ # Editor
39
+ .vscode/
40
+ .idea/
41
+ *.swp
42
+ *.swo
@@ -7,14 +7,18 @@ WORKDIR /app
7
7
 
8
8
  # Copy package files
9
9
  COPY package*.json ./
10
+ COPY prisma ./prisma/
10
11
 
11
12
  # Install dependencies
12
- RUN npm ci --only=production
13
+ RUN npm ci
14
+
15
+ # Generate Prisma Client
16
+ RUN npx prisma generate
13
17
 
14
18
  # Copy source code
15
19
  COPY . .
16
20
 
17
- # Build TypeScript
21
+ # Build Next.js application
18
22
  RUN npm run build
19
23
 
20
24
  # Production stage
@@ -22,14 +26,25 @@ FROM node:20-alpine AS production
22
26
 
23
27
  WORKDIR /app
24
28
 
29
+ # Copy package files for production install
30
+ COPY package*.json ./
31
+ COPY prisma ./prisma/
32
+
33
+ # Install only production dependencies
34
+ RUN npm ci --omit=dev
35
+
36
+ # Generate Prisma Client for production
37
+ RUN npx prisma generate
38
+
25
39
  # Create non-root user
26
40
  RUN addgroup -g 1001 -S nodejs && \
27
41
  adduser -S nodejs -u 1001
28
42
 
29
- # Copy built application
30
- COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
31
- COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
32
- COPY --from=builder --chown=nodejs:nodejs /app/package.json ./
43
+ # Copy built application and config
44
+ COPY --from=builder --chown=nodejs:nodejs /app/.next ./.next
45
+ COPY --from=builder --chown=nodejs:nodejs /app/public ./public
46
+ COPY --from=builder --chown=nodejs:nodejs /app/package.json ./package.json
47
+ COPY --from=builder --chown=nodejs:nodejs /app/next.config.js ./next.config.js
33
48
 
34
49
  # Switch to non-root user
35
50
  USER nodejs
@@ -39,7 +54,7 @@ EXPOSE 3000
39
54
 
40
55
  # Health check
41
56
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
42
- CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
57
+ CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
43
58
 
44
59
  # Start application
45
- CMD ["node", "dist/index.js"]
60
+ CMD ["npm", "start"]
@@ -9,7 +9,7 @@ services:
9
9
  POSTGRES_PASSWORD: postgres
10
10
  POSTGRES_DB: {{snakeCase projectName}}
11
11
  ports:
12
- - "5432:5432"
12
+ - "5434:5432"
13
13
  volumes:
14
14
  - postgres_data:/var/lib/postgresql/data
15
15
  restart: unless-stopped
@@ -0,0 +1,42 @@
1
+ # Dependencies
2
+ node_modules/
3
+ .pnp
4
+ .pnp.js
5
+
6
+ # Build outputs
7
+ dist/
8
+ build/
9
+
10
+ # Environment variables
11
+ .env
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+ !.env.example
17
+
18
+ # Logs
19
+ logs/
20
+ *.log
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
24
+ pnpm-debug.log*
25
+ lerna-debug.log*
26
+
27
+ # Coverage
28
+ coverage/
29
+ .nyc_output
30
+
31
+ # TypeScript
32
+ *.tsbuildinfo
33
+
34
+ # OS
35
+ .DS_Store
36
+ Thumbs.db
37
+
38
+ # Editor
39
+ .vscode/
40
+ .idea/
41
+ *.swp
42
+ *.swo
@@ -7,9 +7,13 @@ WORKDIR /app
7
7
 
8
8
  # Copy package files
9
9
  COPY package*.json ./
10
+ COPY prisma ./prisma/
10
11
 
11
12
  # Install dependencies
12
- RUN npm ci --only=production
13
+ RUN npm ci
14
+
15
+ # Generate Prisma client
16
+ RUN npx prisma generate
13
17
 
14
18
  # Copy source code
15
19
  COPY . .
@@ -30,6 +34,7 @@ RUN addgroup -g 1001 -S nodejs && \
30
34
  COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
31
35
  COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
32
36
  COPY --from=builder --chown=nodejs:nodejs /app/package.json ./
37
+ COPY --from=builder --chown=nodejs:nodejs /app/prisma ./prisma
33
38
 
34
39
  # Switch to non-root user
35
40
  USER nodejs
@@ -7,9 +7,9 @@ services:
7
7
  environment:
8
8
  POSTGRES_USER: postgres
9
9
  POSTGRES_PASSWORD: password
10
- POSTGRES_DB: {{kebabCase projectName}}_db
10
+ POSTGRES_DB: {{kebabCase projectName}}_clean_db
11
11
  ports:
12
- - '5432:5432'
12
+ - '5434:5432'
13
13
  volumes:
14
14
  - postgres_data:/var/lib/postgresql/data
15
15