import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { configureApp } from './app.setup';
import { getJwtSecret } from './common/auth/jwt-secret';

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

  getJwtSecret();
  configureApp(app);

  const port = process.env.PORT;
  if (!port) {
    throw new Error('PORT environment variable is not defined');
  }

  await app.listen(port);
  console.log(`Backend API running on port ${port}`);
}

bootstrap();