Skip to content

feat: update throttle limits for company and user endpoints#1583

Merged
Artuomka merged 1 commit intomainfrom
backend_rate_limits
Feb 9, 2026
Merged

feat: update throttle limits for company and user endpoints#1583
Artuomka merged 1 commit intomainfrom
backend_rate_limits

Conversation

@Artuomka
Copy link
Collaborator

@Artuomka Artuomka commented Feb 9, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 9, 2026 13:49
@Artuomka Artuomka enabled auto-merge February 9, 2026 13:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates API rate-limiting on selected user and company endpoints to better align per-route throttle limits with expected usage patterns, overriding the app-wide default throttler settings.

Changes:

  • Increased throttle limits for /user/login/, /user/otp/verify/, /user/otp/login/, and /company/my/full.
  • Increased throttle limit for /company/user/:companyId (invite user).
  • Added throttling to several user verification flows (email verify request/verify, password reset verify, email change request/verify) and company invite verification.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
backend/src/entities/user/user.controller.ts Adjusts login/OTP throttle limits and adds throttling to multiple email/password verification endpoints.
backend/src/entities/company-info/company-info.controller.ts Tunes throttling for “my full” company info, inviting users, and adds throttling to invite verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +267 to 269
@Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } })
@Get('user/email/verify/:verificationString')
async verifyEmail(
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The throttle configuration object (ttl 60000, isTest() ? 200 : ...) is duplicated across multiple handlers in this controller, which increases the chance of inconsistent limits when changes are needed. Consider extracting shared throttle presets/helpers (e.g., 5/min, 10/min) into a constant or small factory to keep these values centralized.

Copilot uses AI. Check for mistakes.
type: OperationResultMessageDs,
})
@Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } })
@Get('user/email/change/request/')
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET user/email/change/request/ appears to trigger a side effect (sending an email change verification). Using GET for state-changing operations can lead to unintended requests (prefetching/crawlers) and makes caching semantics unsafe. Consider switching this endpoint to POST (or otherwise ensuring it is truly safe/idempotent and not cacheable).

Suggested change
@Get('user/email/change/request/')
@Post('user/email/change/request/')

Copilot uses AI. Check for mistakes.
Comment on lines +213 to 215
@Throttle({ default: { limit: isTest() ? 200 : 10, ttl: 60000 } })
@Get('my/full')
async getUserCompanies(@UserId() userId: string): Promise<FoundUserCompanyInfoDs | FoundUserFullCompanyInfoDs> {
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same inline throttle configuration pattern (ttl 60000, isTest() ? 200 : ...) is repeated for multiple endpoints. Consider centralizing these throttle presets (e.g., constants/factory) to avoid divergence when limits are tuned in the future.

Copilot uses AI. Check for mistakes.
type: OperationResultMessageDs,
})
@Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } })
@Get('user/email/verify/request')
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET user/email/verify/request appears to trigger a side effect (sending an email verification). Using GET for state-changing operations can lead to unintended requests (e.g., prefetching/crawlers) and makes caching semantics unsafe. Consider switching this endpoint to POST (or otherwise ensuring it is truly safe/idempotent and not cacheable).

Suggested change
@Get('user/email/verify/request')
@Post('user/email/verify/request')

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka merged commit cd0d7e3 into main Feb 9, 2026
25 checks passed
@Artuomka Artuomka deleted the backend_rate_limits branch February 9, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant