import { NestFactory } from '@nestjs/core'; import { ValidationPipe } from '@nestjs/common'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); // Global prefix app.setGlobalPrefix('api/v1'); // Validation app.useGlobalPipes( new ValidationPipe({ whitelist: true, transform: true, forbidNonWhitelisted: true, }), ); // CORS app.enableCors({ origin: process.env.CORS_ORIGINS?.split(',') || '*', credentials: true, }); // Swagger const config = new DocumentBuilder() .setTitle('Payment Hub API') .setDescription('Unified DCB Payment Aggregation Platform') .setVersion('1.0.0') .addBearerAuth() .addTag('payments') .addTag('subscriptions') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api/docs', app, document); app.getHttpAdapter().get('/api/swagger-json', (req, res) => { res.json(document); }); const port = process.env.PORT || 3000; await app.listen(port); console.log(`Application is running on: http://localhost:${port}`); console.log(`Swagger docs: http://localhost:${port}/api/docs`); console.log(`Swagger docs: http://localhost:${port}/api/swagger-json`); } bootstrap();