import { NestFactory } from '@nestjs/core';
import { Logger } from '@nestjs/common';
import { AppModule } from './app.module';

async function bootstrap() {
  const logger = new Logger('RealtimeService');
  const app = await NestFactory.create(AppModule);

  app.enableCors({
    origin: process.env.CORS_ORIGIN ?? '*',
    credentials: true,
  });

  const port = process.env.PORT ?? 3004;
  await app.listen(port);

  logger.log(`Analytics realtime service running on port ${port}`);
  logger.log(`WebSocket gateway available at ws://localhost:${port}`);
}

bootstrap();
