forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
41 lines (33 loc) · 1.17 KB
/
Copy pathmain.ts
File metadata and controls
41 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
import { TransformInterceptor } from './common/interceptors/transform.interceptor';
import { ConfigService } from '@nestjs/config';
import { setupSwagger } from '../docs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Get config service
const configService = app.get(ConfigService);
// Enable CORS
app.enableCors({
origin: configService.get('app.corsOrigin'),
});
// Global validation pipe
app.useGlobalPipes(new ValidationPipe({
whitelist: true,
transform: true,
forbidUnknownValues: true,
}));
// Global exception filter
app.useGlobalFilters(new HttpExceptionFilter());
// Global response transform interceptor
app.useGlobalInterceptors(new TransformInterceptor());
// Setup Swagger
setupSwagger(app);
// Start server
const port = configService.get('app.port');
await app.listen(port);
console.log(`Application is running on: http://localhost:${port}`);
}
bootstrap();