Skip to content

Social links: rate limiting on create/update#266

Merged
aji70 merged 3 commits intoMyFanss:mainfrom
iGEORGE17:fix#210
Mar 2, 2026
Merged

Social links: rate limiting on create/update#266
aji70 merged 3 commits intoMyFanss:mainfrom
iGEORGE17:fix#210

Conversation

@iGEORGE17
Copy link
Contributor

feat: add rate limiting to social links create and update endpoints

Summary

Adds rate limiting to the POST /social-links and PATCH /social-links/:id endpoints to prevent abuse. Excess requests return 429 Too Many Requests. Uses the existing @nestjs/throttler package already present in the project — no new dependencies added.


Changes

  • Added @UseGuards(ThrottlerGuard) and @Throttle({ default: { limit: 5, ttl: 60 } }) to create and update methods in SocialLinkController
  • Registered ThrottlerModule.forRoot([{ ttl: 60, limit: 10 }]) in AppModule
  • Throttling is scoped to social links only — APP_GUARD is not used globally
  • Added integration test that hits POST /social-links 5 times then expects 429 on the 6th request

How to Test

npm test -- social-links

Acceptance Criteria

Criteria Status
Excess requests get 429
Limit is per user or IP ✅ ThrottlerGuard tracks by IP by default
Tests pass

Notes

  • Uses @nestjs/throttler v6.5.0 already in the project — no new packages added
  • Limit of 5 requests per 60 seconds per IP — can be adjusted in the @Throttle decorator
  • @Throttle uses v6 object syntax: { default: { limit, ttl } }
Screenshot 2026-02-25 at 17 43 13

Closes #210

Copy link
Contributor

@aji70 aji70 left a comment

Choose a reason for hiding this comment

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

LFG

@aji70 aji70 merged commit 133a7a1 into MyFanss:main Mar 2, 2026
3 checks passed
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.

Social links: rate limiting on create/update

2 participants