traintrape-moi/server/src/main.ts

24 lines
830 B
TypeScript
Raw Normal View History

2024-12-07 12:06:15 +00:00
import { NestFactory, Reflector } from '@nestjs/core'
2024-12-07 09:24:41 +00:00
import { AppModule } from './app.module'
2024-12-07 09:32:44 +00:00
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
2024-12-07 12:06:15 +00:00
import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common'
2024-12-01 11:30:56 +00:00
async function bootstrap() {
2024-12-07 09:24:41 +00:00
const app = await NestFactory.create(AppModule)
2024-12-07 12:06:15 +00:00
2024-12-07 15:50:26 +00:00
app.useGlobalPipes(new ValidationPipe({ transform: true }))
2024-12-07 12:06:15 +00:00
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)))
2024-12-07 09:32:44 +00:00
const config = new DocumentBuilder()
.setTitle('Traintrape-moi')
.setDescription('API permettant de stocker les données de Traintrape-moi')
.setVersion('1.0')
2024-12-07 12:06:15 +00:00
.addBearerAuth()
2024-12-07 09:32:44 +00:00
.build()
const document = SwaggerModule.createDocument(app, config)
2024-12-07 12:06:15 +00:00
SwaggerModule.setup('', app, document)
2024-12-07 09:24:41 +00:00
await app.listen(process.env.PORT ?? 3000)
2024-12-01 11:30:56 +00:00
}
2024-12-07 09:24:41 +00:00
bootstrap()