Utilisation d'un préfixe global
This commit is contained in:
		| @@ -1,2 +1,3 @@ | |||||||
| DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi" | DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi" | ||||||
| JWT_SECRET="CHANGE_ME" | JWT_SECRET="CHANGE_ME" | ||||||
|  | API_GLOBAL_PREFIX="api" | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common' | |||||||
| async function bootstrap() { | async function bootstrap() { | ||||||
|   const app = await NestFactory.create(AppModule, { cors: true }) |   const app = await NestFactory.create(AppModule, { cors: true }) | ||||||
|  |  | ||||||
|  |   app.setGlobalPrefix(process.env.API_GLOBAL_PREFIX ?? '') | ||||||
|   app.useGlobalPipes(new ValidationPipe({ transform: true })) |   app.useGlobalPipes(new ValidationPipe({ transform: true })) | ||||||
|   app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector))) |   app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector))) | ||||||
|  |  | ||||||
| @@ -17,7 +18,7 @@ async function bootstrap() { | |||||||
|     .build() |     .build() | ||||||
|   const document = SwaggerModule.createDocument(app, config) |   const document = SwaggerModule.createDocument(app, config) | ||||||
|  |  | ||||||
|   SwaggerModule.setup('', app, document) |   SwaggerModule.setup(process.env.API_GLOBAL_PREFIX ?? '', app, document) | ||||||
|   await app.listen(process.env.PORT ?? 3000) |   await app.listen(process.env.PORT ?? 3000) | ||||||
| } | } | ||||||
| bootstrap() | bootstrap() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user