From b84474e611dbdfd2c03bb2a230cc910884617c2c Mon Sep 17 00:00:00 2001 From: Radhay Date: Tue, 10 May 2022 23:52:24 +0530 Subject: [PATCH] Throttle config for DST --- src/admin/admin.service.ts | 11 ++++++++++- src/dst/dst.controller.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/admin/admin.service.ts b/src/admin/admin.service.ts index 6c85ce2..14bcdf9 100644 --- a/src/admin/admin.service.ts +++ b/src/admin/admin.service.ts @@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common'; import { ResponseCode, ResponseStatus, UsersResponse } from './admin.interface'; import { FusionauthService } from './fusionauth/fusionauth.service'; import { v4 as uuidv4 } from 'uuid'; -import { map } from 'rxjs'; +import { catchError, map } from 'rxjs'; @Injectable() export class AdminService { @@ -63,6 +63,9 @@ export class AdminService { 'Content-Type': 'application/json' }}).pipe( map(response => response.status===200?{msg: "Password changed successfully"}:{msg:"Password cannot be changed"}), + catchError(e=>{ + return e.data; + }) ); } @@ -73,6 +76,9 @@ export class AdminService { 'Content-Type': 'application/json' }}).pipe( map(response => response.data), + catchError(e=>{ + return e.data; + }) ); } @@ -83,6 +89,9 @@ export class AdminService { 'Content-Type': 'application/json' }}).pipe( map(response => response.data), + catchError(e=>{ + return e.data; + }) ); } } diff --git a/src/dst/dst.controller.ts b/src/dst/dst.controller.ts index 449c5a6..7dfd080 100644 --- a/src/dst/dst.controller.ts +++ b/src/dst/dst.controller.ts @@ -36,7 +36,7 @@ export class DstController { // return { resp }; // } - @Throttle(10, 86400) + @Throttle(parseInt(process.env.DST_API_LIMIT), parseInt(process.env.DST_API_TTL)) @Get('/:role/loginOrRegister') async loginOrRegister(@Param('role') role: string, @Query('id') id, @Query('phone') phone, @Query('otp') otp, @Query('dob') dob): Promise { let resp: SignupResponse;