feat: add Swagger API documentation setup in main application bootstrap
This commit is contained in:
parent
2f9d2d1df1
commit
b61f297497
@ -1,6 +1,7 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
@ -54,10 +55,22 @@ async function bootstrap() {
|
||||
}
|
||||
|
||||
// Préfixe global pour les routes API
|
||||
app.setGlobalPrefix(configService.get<string>('API_PREFIX', 'api'));
|
||||
const apiPrefix = configService.get<string>('API_PREFIX', 'api');
|
||||
app.setGlobalPrefix(apiPrefix);
|
||||
|
||||
// Configuration de Swagger
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Group Maker API')
|
||||
.setDescription('API documentation for the Group Maker application')
|
||||
.setVersion('1.0')
|
||||
.addBearerAuth()
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api/docs', app, document);
|
||||
|
||||
const port = configService.get<number>('PORT', 3000);
|
||||
await app.listen(port);
|
||||
console.log(`Application is running on: http://localhost:${port}`);
|
||||
console.log(`Swagger documentation is available at: http://localhost:${port}/api/docs`);
|
||||
}
|
||||
bootstrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user