import { ValidationPipe } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); const configService = app.get(ConfigService); app.enableCors({ origin: configService.get('FRONTEND_URL'), }); const config = new DocumentBuilder() .setTitle('Home Manager') .setDescription('Home manager API') .setVersion('1.0') .addTag('users') .addTag('groups') .addTag('storage') .addTag('buildings') .addSecurity('Bearer token', { name: 'Authorization', type: 'http', scheme: 'bearer', bearerFormat: 'JWT', in: 'header', }) .addSecurity('Email and Password', { type: 'http', description: 'For acquiring the access token', scheme: 'basic', }) .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); app.useGlobalPipes( new ValidationPipe({ forbidNonWhitelisted: true, whitelist: true, }), ); await app.listen(+configService.get('PORT'), configService.get('HOST')); } bootstrap();