diff --git a/src/controller/po-rep/po-rep.controller.ts b/src/controller/po-rep/po-rep.controller.ts index 077e3e8..083def9 100644 --- a/src/controller/po-rep/po-rep.controller.ts +++ b/src/controller/po-rep/po-rep.controller.ts @@ -6,7 +6,6 @@ import { Inject, Query, UseInterceptors, - ValidationPipe, } from '@nestjs/common'; import { ApiOkResponse, ApiOperation } from '@nestjs/swagger'; import { PoRepService } from 'src/service/po-rep/po-rep.service'; @@ -38,8 +37,7 @@ export class PoRepController extends ControllerBase { type: PoRepDealsList, }) public getDeals( - @Query(new ValidationPipe({ transform: true })) - query: PoRepDealsListParameters, + @Query() query: PoRepDealsListParameters, ): Promise { return this.poRepService.getDeals(query); } @@ -52,7 +50,7 @@ export class PoRepController extends ControllerBase { type: [PoRepOnboardedDataHistoryEntry], }) public async getOnboardedDataHistory( - @Query(new ValidationPipe()) query: PoRepOnboardedDataHistoryParameters, + @Query() query: PoRepOnboardedDataHistoryParameters, ): Promise { return this.poRepService.getOnboardedDataHistory(query); } @@ -65,7 +63,7 @@ export class PoRepController extends ControllerBase { type: [PoRepDealsValueHistoryEntry], }) public async getDealsValueHistory( - @Query(new ValidationPipe()) query: PoRepDealsValueHistoryParameters, + @Query() query: PoRepDealsValueHistoryParameters, ): Promise { return this.poRepService.getDealsValueHistory(query); } @@ -79,7 +77,7 @@ export class PoRepController extends ControllerBase { type: [PoRepDealsPaymentsHistoryEntry], }) public async getPaymentsHistory( - @Query(new ValidationPipe()) + @Query() query: PoRepDealsPaymentsHistoryParameters, ): Promise { return this.poRepService.getDealsPaymentsSummaryHistory(query); diff --git a/src/main.ts b/src/main.ts index 7312676..5c24f88 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,4 @@ +import { ValidationPipe } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import * as packageJson from '../package.json'; @@ -11,6 +12,13 @@ async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableShutdownHooks(); app.enableCors(); + app.useGlobalPipes( + new ValidationPipe({ + transform: true, + whitelist: true, + forbidNonWhitelisted: true, + }), + ); // setup swagger const config = new DocumentBuilder()