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); app.setGlobalPrefix('api'); // Request logging app.use((req: any, _res: any, next: any) => { console.log(`[REQ] ${req.method} ${req.url} auth=${req.headers.authorization ? 'yes' : 'no'}`); next(); }); app.useGlobalPipes( new ValidationPipe({ whitelist: false, forbidNonWhitelisted: false, transform: true, }), ); app.enableCors({ origin: ['http://localhost', 'http://localhost:5173'], credentials: true, }); const config = new DocumentBuilder() .setTitle('HOA LedgerIQ API') .setDescription('API for the HOA LedgerIQ') .setVersion('0.1.0') .addBearerAuth() .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api/docs', app, document); await app.listen(3000); console.log('Backend running on port 3000'); } bootstrap();