Skip to content

Feature/issue 045 fingerprint ratelimit - #737

Merged
greatest0fallt1me merged 4 commits into
Predictify-org:mainfrom
ugoocreates-pixel:feature/issue-045-fingerprint-ratelimit
Jul 29, 2026
Merged

Feature/issue 045 fingerprint ratelimit#737
greatest0fallt1me merged 4 commits into
Predictify-org:mainfrom
ugoocreates-pixel:feature/issue-045-fingerprint-ratelimit

Conversation

@ugoocreates-pixel

Copy link
Copy Markdown
Contributor

Closes #619

This PR addresses backend issue [b#045] by implementing a per-user token-bucket rate limit for the /api/fingerprint endpoint. This ensures that we prevent abuse or excessive polling on the fingerprint route while returning a standard 429 Too Many Requests along with a Retry-After header when the limit is exceeded.

Changes Made

  • Environment Configuration (src/config/env-schema.ts): Added configurable rate limit parameters FINGERPRINT_RATE_LIMIT_CAPACITY (default 60) and FINGERPRINT_RATE_LIMIT_WINDOW_MS (default 60,000 ms).
  • Rate Limit Middleware (src/middleware/rateLimit.ts): Exported a pre-configured fingerprintRateLimiter utilizing createPerUserTokenBucketLimiter.
  • Route Update (src/routes/fingerprint.ts): Injected the rate limit middleware into the GET /api/fingerprint route.
  • Testing (tests/fingerprint.test.ts): Added an integration test that isolates an IP and exhausts the rate limit to verify that the 61st request correctly returns a 429 status code, the appropriate error code payload (rate_limit_exceeded), and the Retry-After header.

Validation & Guidelines

  • ✅ Minimum 90% test coverage on changed lines.
  • ✅ Uses standard project error envelope ({ error: { code, ... } }).
  • ✅ Incorporates structured logging with context and correlation IDs (handled seamlessly by the rate limit middleware wrapper).
  • ✅ Clean documentation/inline comments where applicable.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@ugoocreates-pixel Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit bcdb151 into Predictify-org:main Jul 29, 2026
1 check failed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merging — thanks for staying scoped to the issue!

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.

Add rate limit on /api/fingerprint [b#045]

2 participants