Skip to content

feat(api): IP-based rate limiting for POST /api/readings and GET /api/verify#685

Merged
AnnabelJoe merged 1 commit into
AnnabelJoe:mainfrom
georgeefaith:feat/491-ip-rate-limiting
Jun 27, 2026
Merged

feat(api): IP-based rate limiting for POST /api/readings and GET /api/verify#685
AnnabelJoe merged 1 commit into
AnnabelJoe:mainfrom
georgeefaith:feat/491-ip-rate-limiting

Conversation

@georgeefaith

Copy link
Copy Markdown
Contributor

Summary

Closes #491

Wires the existing lib/rate-limit.ts IP rate limiter into both public endpoints.

Changes

  • POST /api/readings — 10 req / 60 s per IP. Returns 429 with Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset headers and retryAfter in the JSON body.
  • GET /api/verify — 30 req / 60 s per IP, same response headers.
  • Removes defunct no-op checkRateLimitByKey stub from the readings route.
  • Uses getClientIp() (respects x-real-ip / x-forwarded-for for Vercel/Cloudflare).

Acceptance criteria

  • Configurable rate limit for POST /api/readings
  • Verified endpoint enforces a request cap
  • Rate limit response includes retry guidance

…/api/verify (AnnabelJoe#491)

- POST /api/readings: 10 requests / 60s per IP with Retry-After, X-RateLimit-* headers
- GET /api/verify: 30 requests / 60s per IP with same headers
- Uses existing lib/rate-limit.ts (checkRateLimit + getClientIp)
- Removes dead no-op checkRateLimitByKey stub from readings route
- 429 response includes retryAfter in body for client guidance

Closes AnnabelJoe#491
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@georgeefaith 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

@AnnabelJoe AnnabelJoe merged commit 3912f27 into AnnabelJoe:main Jun 27, 2026
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 explicit request rate limiting for read/write APIs

2 participants