import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as https from 'https';
import * as tls from 'tls';

// Força TLS 1.2 compatível com Windows Server antigo
(tls as any).DEFAULT_MIN_VERSION = 'TLSv1';
(https.globalAgent as any).options = {
  ...(https.globalAgent as any).options,
  secureProtocol: 'TLS_method',
  rejectUnauthorized: false,
};

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.enableCors({
    origin: '*',
    methods: ['GET', 'POST'],
  });

  const port = process.env.PORT || 3006;
  await app.listen(port);
  console.log(`\n  HCM Dashboard Backend rodando em http://localhost:${port}\n`);
}

bootstrap();
