From e0f8633f406bea7b2c180179f5d8baa2b77fb7c7 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Fri, 29 Aug 2025 15:35:39 +0000 Subject: [PATCH] feat: adjust throttling limits based on test environment and skip throttling for token validation --- backend/src/entities/company-info/company-info.controller.ts | 3 ++- backend/src/entities/connection/connection.controller.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/entities/company-info/company-info.controller.ts b/backend/src/entities/company-info/company-info.controller.ts index 6a094f4fc..3957145f7 100644 --- a/backend/src/entities/company-info/company-info.controller.ts +++ b/backend/src/entities/company-info/company-info.controller.ts @@ -85,6 +85,7 @@ import { AddCompanyTabTitleDto } from './application/data-structures/add-company import { FoundCompanyTabTitleRO } from './application/data-structures/found-company-tab-title.ro.js'; import { FoundCompanyWhiteLabelPropertiesRO } from './application/dto/found-company-white-label-properties.ro.js'; import { PaidFeatureGuard } from '../../guards/paid-feature.guard.js'; +import { isTest } from '../../helpers/app/is-test.js'; @UseInterceptors(SentryInterceptor) @Controller('company') @@ -205,7 +206,7 @@ export class CompanyInfoController { type: FoundUserFullCompanyInfoDs, }) @UseGuards(CompanyUserGuard) - @Throttle({ default: { limit: 5, ttl: 60000 } }) + @Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } }) @Get('my/full') async getUserCompanies(@UserId() userId: string): Promise { return await this.getUserFullCompanyInfoUseCase.execute(userId); diff --git a/backend/src/entities/connection/connection.controller.ts b/backend/src/entities/connection/connection.controller.ts index e3f8b40dd..666b34d61 100644 --- a/backend/src/entities/connection/connection.controller.ts +++ b/backend/src/entities/connection/connection.controller.ts @@ -82,6 +82,7 @@ import { } from './use-cases/use-cases.interfaces.js'; import { TokenValidationResult } from './use-cases/validate-connection-token.use.case.js'; import { isTestConnectionUtil } from './utils/is-test-connection-util.js'; +import { SkipThrottle } from '@nestjs/throttler'; @UseInterceptors(SentryInterceptor) @Controller() @@ -651,6 +652,7 @@ export class ConnectionController { type: Boolean, }) @ApiQuery({ name: 'token', required: true }) + @SkipThrottle() @Get('/connection/token/') async validateConnectionAgentToken(@Query('token') token: string): Promise { if (!token || typeof token !== 'string' || token.length === 0) {