import { NestFactory } from '@nestjs/core'; import { ValidationPipe, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { AppModule } from './app.module'; async function bootstrap() { const logger = new Logger('Bootstrap'); const app = await NestFactory.create(AppModule, { logger: ['error', 'warn', 'log', 'debug'], }); // Global validation pipe app.useGlobalPipes( new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true, transformOptions: { enableImplicitConversion: true, }, }), ); // CORS - only allow internal services app.enableCors({ origin: false, // Disable public CORS - only internal services should access }); const configService = app.get(ConfigService); const port = configService.get('app.port') || 3002; const env = configService.get('app.env') || 'development'; await app.listen(port); logger.log(`Backup Service is running on port ${port} in ${env} mode`); logger.log(`Health check: http://localhost:${port}/health`); } bootstrap();