Ajout IoAdapter pour les websockets en production

This commit is contained in:
Emmy D'Anello 2024-12-17 01:32:10 +01:00
parent 20f8fd515f
commit 0b9df38139
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -2,11 +2,13 @@ import { NestFactory, Reflector } from '@nestjs/core'
import { AppModule } from './app.module' import { AppModule } from './app.module'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger' import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common' import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common'
import { IoAdapter } from '@nestjs/platform-socket.io'
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.setGlobalPrefix(process.env.API_GLOBAL_PREFIX ?? '')
app.useWebSocketAdapter(new IoAdapter(app))
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)))