From 773e53de3b551e67cf51540ee5c00e7cc913ef28 Mon Sep 17 00:00:00 2001 From: Emile Bex Date: Tue, 24 Oct 2023 17:15:00 +0200 Subject: [PATCH 1/2] fix(throttler): make throttler more restrictive --- src/app.module.ts | 2 +- src/auth/auth.controller.ts | 2 +- src/contacts/contacts.controller.ts | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app.module.ts b/src/app.module.ts index 6a9a2be5..e9a65520 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -84,7 +84,7 @@ export function getSequelizeOptions(): SequelizeModuleOptions { SequelizeModule.forRoot(getSequelizeOptions()), ThrottlerModule.forRoot({ ttl: 60, - limit: 100, + limit: 60, }), BullModule.forRoot({ redis: ENV === 'dev-test' || ENV === 'test' ? {} : getRedisOptions(), diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 63450c17..241c8386 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -143,7 +143,7 @@ export class AuthController { return updatedUser; } - @Throttle(100, 60) + @Throttle(60, 60) @Get('current') async getCurrent(@UserPayload('id', new ParseUUIDPipe()) id: string) { const updatedUser = await this.authService.updateUser(id, { diff --git a/src/contacts/contacts.controller.ts b/src/contacts/contacts.controller.ts index 8f89dee2..77a5dc14 100644 --- a/src/contacts/contacts.controller.ts +++ b/src/contacts/contacts.controller.ts @@ -5,6 +5,7 @@ import { Get, Post, } from '@nestjs/common'; +import { Throttle } from '@nestjs/throttler'; import { Public } from 'src/auth/guards'; import { ContactCompanyFormDto, @@ -25,6 +26,7 @@ import { InscriptionCandidateFormDto } from './dto/inscription-candidate-form.dt import { InscriptionCandidateFormPipe } from './dto/inscription-candidate-form.pipe'; // TODO change to /contacts +@Throttle(20, 60) @Controller('contact') export class ContactsController { constructor(private readonly contactsService: ContactsService) {} From ecb0bff018d43ea27e5c3d7b72fe2362e0b9f2cf Mon Sep 17 00:00:00 2001 From: Emile Bex Date: Tue, 24 Oct 2023 17:16:06 +0200 Subject: [PATCH 2/2] v2.15.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 355b23aa..17ba0a44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "linkedout-backend", - "version": "2.15.2", + "version": "2.15.3", "license": "ISC", "engines": { "node": "16.x"