35 lines
865 B
TypeScript
35 lines
865 B
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { AppModule } from './app.module';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
// Global validation pipe
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
whitelist: true,
|
|
forbidNonWhitelisted: true,
|
|
transform: true,
|
|
}),
|
|
);
|
|
|
|
// Enable CORS
|
|
app.enableCors({
|
|
origin: process.env.CORS_ORIGINS?.split(',') || ['http://localhost:5173'],
|
|
credentials: true,
|
|
});
|
|
|
|
// API prefix
|
|
app.setGlobalPrefix('api/v1');
|
|
|
|
const configService = app.get(ConfigService);
|
|
const port = configService.get<number>('CONVERSATION_SERVICE_PORT') || 3002;
|
|
|
|
await app.listen(port);
|
|
console.log(`Conversation Service is running on port ${port}`);
|
|
}
|
|
|
|
bootstrap();
|