import 'dotenv/config';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as fs from 'fs';
import * as path from 'path';

async function bootstrap() {
  const httpsOptions = {
    key: fs.readFileSync(path.resolve(__dirname, '../cert/127.0.0.1+1-key.pem')),
    cert: fs.readFileSync(path.resolve(__dirname, '../cert/127.0.0.1+1.pem')),
  };

  const app = await NestFactory.create(AppModule, { httpsOptions });

  app.enableCors({
    origin: ['https://192.168.100.100:4200', 'https://192.168.100.79:4200', 'https://localhost:4200'],
    credentials: true,
  });

  await app.listen(process.env.PORT ?? 3000, process.env.HOST ?? '0.0.0.0');
}
bootstrap();
