From 0a3fe8c243a3d4642828dfe9beee83d6ba90f93a Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sun, 15 Dec 2024 20:46:53 +0100 Subject: [PATCH] =?UTF-8?q?Utilisation=20d'un=20pr=C3=A9fixe=20global?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/.env.example | 1 + server/src/main.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server/.env.example b/server/.env.example index 05878e5..89bc53a 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1,2 +1,3 @@ DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi" JWT_SECRET="CHANGE_ME" +API_GLOBAL_PREFIX="api" diff --git a/server/src/main.ts b/server/src/main.ts index fc82f61..7f7936d 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -6,6 +6,7 @@ import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common' async function bootstrap() { const app = await NestFactory.create(AppModule, { cors: true }) + app.setGlobalPrefix(process.env.API_GLOBAL_PREFIX ?? '') app.useGlobalPipes(new ValidationPipe({ transform: true })) app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector))) @@ -17,7 +18,7 @@ async function bootstrap() { .build() 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) } bootstrap()