import { NestFactory } from '@nestjs/core'; import { ValidationPipe } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import helmet from 'helmet'; import compression from 'compression'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); const configService = app.get(ConfigService); app.use(helmet()); app.use(compression()); app.enableCors({ origin: configService.get('APP_URL') || 'http://localhost:3000', credentials: true }); app.useGlobalPipe(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true })); app.setGlobalPrefix('api'); const port = configService.get('PORT') || 3000; await app.listen(port); console.log(`API running on port ${port}`); } bootstrap();