-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
27 lines (22 loc) · 1.03 KB
/
main.ts
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
import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import { AppModule } from './app.module';
import { AllExceptionFilter } from './infrastructure/common/filters/exception.filter';
import { LoggingInterceptor } from './infrastructure/common/interceptors/logger.interceptor';
import { ResponseInterceptor } from './infrastructure/common/interceptors/response.interceptor';
import { LoggerService } from './infrastructure/logger/logger.service';
async function bootstrap() {
const app = await NestFactory.create(AppModule, { cors: true });
app.useGlobalPipes(
new ValidationPipe({
transform: true,
whitelist: true,
}),
);
app.useGlobalFilters(new AllExceptionFilter(new LoggerService()));
app.useGlobalInterceptors(new LoggingInterceptor(new LoggerService()));
app.useGlobalInterceptors(new ResponseInterceptor());
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
await app.listen(3000);
}
bootstrap();