import { NestFactory } from '@nestjs/core'; import { ValidationPipe, Logger } from '@nestjs/common'; import { AppModule } from './app.module'; import { AllExceptionsFilter, HttpExceptionFilter } from './common/filters'; async function bootstrap() { const logger = new Logger('Bootstrap'); const app = await NestFactory.create(AppModule); // Global prefix for all routes app.setGlobalPrefix('api/v1'); // Enable CORS app.enableCors({ origin: process.env.FRONTEND_URL || 'http://localhost:5173', credentials: true, }); // Global exception filters (order matters - most specific last) app.useGlobalFilters( new AllExceptionsFilter(), new HttpExceptionFilter(), ); // Global validation pipe app.useGlobalPipes( new ValidationPipe({ whitelist: true, // Strip properties that don't have decorators forbidNonWhitelisted: true, // Throw error if non-whitelisted properties are present transform: true, // Automatically transform payloads to DTO instances transformOptions: { enableImplicitConversion: true, }, }), ); const port = process.env.PORT || 3000; await app.listen(port); logger.log(`🚀 Application is running on: http://localhost:${port}/api/v1`); logger.log(`📚 Environment: ${process.env.NODE_ENV || 'development'}`); logger.log(`🔐 Auth0 Domain: ${process.env.AUTH0_DOMAIN || 'not configured'}`); } bootstrap();