it0/packages/services/notification-service/src/main.ts

31 lines
914 B
TypeScript

import { NestFactory } from '@nestjs/core';
import { Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { NotificationModule } from './notification.module';
const logger = new Logger('NotificationService');
process.on('unhandledRejection', (reason) => {
logger.error(`Unhandled Rejection: ${reason}`);
});
process.on('uncaughtException', (error) => {
logger.error(`Uncaught Exception: ${error.message}`, error.stack);
});
async function bootstrap() {
const app = await NestFactory.create(NotificationModule);
const config = app.get(ConfigService);
const port = config.get<number>('NOTIFICATION_SERVICE_PORT', 3013);
app.enableCors();
await app.listen(port);
logger.log(`notification-service running on port ${port}`);
}
bootstrap().catch((err) => {
logger.error(`Failed to start notification-service: ${err.message}`, err.stack);
process.exit(1);
});