main.ts 608 B

12345678910111213141516171819
  1. import { NestFactory } from '@nestjs/core';
  2. import { AppController } from './app.controller';
  3. import { AppModule } from './app.module';
  4. async function bootstrap() {
  5. const app = await NestFactory.create(AppModule);
  6. // Enable CORS for WebSocket connections
  7. app.enableCors();
  8. // Set app instance on controller for restart functionality
  9. const appController = app.get(AppController);
  10. appController.setApp(app);
  11. const port = process.env.PORT ? Number(process.env.PORT) : 3001;
  12. console.log(`Starting API service with WebSocket support on port ${port}`);
  13. await app.listen(port);
  14. }
  15. bootstrap();