forked from Ynov/ptitspas-ynov-back
31 lines
913 B
TypeScript
31 lines
913 B
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { SwaggerModule } from '@nestjs/swagger/dist/swagger-module';
|
|
import { DocumentBuilder } from '@nestjs/swagger';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
const configService = app.get(ConfigService);
|
|
|
|
const port = configService.get<number>('app.port', 3000);
|
|
app.setGlobalPrefix('api/v1');
|
|
|
|
const config = new DocumentBuilder()
|
|
.setTitle("P'titsPas API")
|
|
.setVersion('1.0.0')
|
|
.build();
|
|
|
|
const document = SwaggerModule.createDocument(app, config);
|
|
SwaggerModule.setup('api/docs', app, document);
|
|
|
|
await app.listen(port);
|
|
console.log(`✅ P'titsPas API is running on: ${await app.getUrl()}`);
|
|
}
|
|
|
|
bootstrap().catch((err) => {
|
|
console.error('❌ Error starting the application:', err);
|
|
process.exit(1);
|
|
});
|