Skip to content

Commit

Permalink
Merge pull request #85 from Samagra-Development/hotfix/validation-bug
Browse files Browse the repository at this point in the history
Fixed validations issue
  • Loading branch information
amit-s19 authored Sep 1, 2023
2 parents 2d8528e + c21c4e1 commit ac66239
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/api/api.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Param,
Patch,
Post,
Query, UnprocessableEntityException, UseInterceptors,
Query, UnprocessableEntityException, UseInterceptors, UsePipes, ValidationPipe,
} from '@nestjs/common';
import {
SignupResponse,
Expand Down Expand Up @@ -50,6 +50,7 @@ export class ApiController {
}

@Get('sendOTP')
@UsePipes(new ValidationPipe({ transform: true }))
async sendOTP(
@Query() params: SendOtpDto,
@Headers('x-application-id') applicationId?,
Expand Down Expand Up @@ -78,12 +79,14 @@ export class ApiController {
}

@Get('verifyOTP')
@UsePipes(new ValidationPipe({ transform: true }))
async verifyOTP(@Query() params: VerifyOtpDto): Promise<any> {
const status: SMSResponse = await this.otpService.verifyOTP(params);
return { status };
}

@Post('login')
@UsePipes(new ValidationPipe({ transform: true }))
async login(
@Body() user: LoginDto,
@Headers('authorization') authHeader,
Expand Down Expand Up @@ -314,6 +317,7 @@ export class ApiController {
}

@Patch('/changePassword/update')
@UsePipes(new ValidationPipe({ transform: true }))
async changePassword(
@Headers('authorization') authHeader,
@Headers('x-application-id') applicationId,
Expand All @@ -327,6 +331,7 @@ export class ApiController {
}

@Post('login/otp')
@UsePipes(new ValidationPipe({ transform: true }))
async loginWithOtp(
@Body() user: LoginDto,
@Headers('authorization') authHeader,
Expand Down
7 changes: 1 addition & 6 deletions src/api/api.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpModule } from '@nestjs/axios';
import { Module, ValidationPipe } from '@nestjs/common';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ApiController } from './api.controller';
import { ApiService } from './api.service';
Expand All @@ -11,7 +11,6 @@ import { GupshupService } from './sms/gupshup/gupshup.service';
import { SmsService } from './sms/sms.service';
import got from 'got/dist/source';
import { CdacService } from './sms/cdac/cdac.service';
import { APP_PIPE } from '@nestjs/core';

const otpServiceFactory = {
provide: OtpService,
Expand Down Expand Up @@ -54,10 +53,6 @@ const otpServiceFactory = {
otpServiceFactory,
QueryGeneratorService,
ConfigResolverService,
{
provide: APP_PIPE,
useValue: new ValidationPipe({ transform: true }),
},
],
})
export class ApiModule {
Expand Down

0 comments on commit ac66239

Please sign in to comment.