import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import express from 'express';
import { ExpressAdapter } from '@nestjs/platform-express';
import { HttpExceptionFilter } from './nest-utils/http-exception.filter';
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
  const expressApp = express();
  const app = await NestFactory.create(AppModule, new ExpressAdapter(expressApp), {
    logger: console,
    cors: {
      origin: process.env.CORS_ORIGIN,
      preflightContinue: false,
      optionsSuccessStatus: 200,
      exposedHeaders: ['Content-Disposition'],
    },
  });
  app.useGlobalFilters(new HttpExceptionFilter());
  // app.useGlobalPipes(new ValidationPipe({ transform: true }));
  // const app = await NestFactory.create(AppModule);
  await app.listen(4000);
}

bootstrap();
