import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { I18nValidationExceptionFilter, I18nValidationPipe } from 'nestjs-i18n'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { ResponseInterceptor } from './common/interceptors/response.interceptor'; import helmet from 'helmet'; async function bootstrap() { const app = await NestFactory.create(AppModule); app.useGlobalPipes( new I18nValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true, transformOptions: { enableImplicitConversion: true, }, }), ); app.useGlobalFilters( new I18nValidationExceptionFilter({ errorFormatter: (errors) => { return errors.map((err) => ({ field: err.property, errors: Object.values(err.constraints ?? {}), })); }, }), ); app.useGlobalInterceptors(new ResponseInterceptor()); app.enableCors({ origin: ['http://localhost:5173'], credentials: true, }); app.use(helmet()); const config = new DocumentBuilder() .setTitle('Borna API') .setDescription('Borna API Documentation') .setVersion('1.0') .setLicense('MIT', 'https://opensource.org/license/mit') .addServer('http://localhost:3000') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api/v1', app, document); await app.listen(process.env.PORT ?? 3000); } bootstrap();