Skip to content

feat: Add reusable API rate limiting helpers#1237

Open
msgem0523 wants to merge 1 commit into
Vets-Who-Code:masterfrom
msgem0523:feature/msgem0523/912-api-rate-limiting-middleware
Open

feat: Add reusable API rate limiting helpers#1237
msgem0523 wants to merge 1 commit into
Vets-Who-Code:masterfrom
msgem0523:feature/msgem0523/912-api-rate-limiting-middleware

Conversation

@msgem0523

Copy link
Copy Markdown
Contributor

Summary

This PR extends the existing rate limiting implementation by adding reusable middleware helpers and configurable rate limit tiers while maintaining backward compatibility with the current checkRateLimit() implementation.

Changes

  • Added configurable RATE_LIMITS presets.
  • Added RateLimitType for standardized rate limit categories.
  • Added applyRateLimit() helper for reusable rate limit enforcement.
  • Added withRateLimit() wrapper for middleware-style usage.
  • Applied rate limiting to the AI chat endpoint using the new helper.

Why

While investigating Issue #912, I found an existing rate-limit.ts implementation already protecting several API routes. Rather than introducing a second implementation, I extended the existing helper to make it reusable across future API endpoints while preserving existing functionality.

Testing

  • Verified the project builds until reaching the existing unrelated TypeScript error in src/pages/admin/courses.tsx:

    • Parameter 'course' implicitly has an 'any' type.
  • Confirmed no additional build errors were introduced by these changes.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@msgem0523 is attempting to deploy a commit to the vetswhocode-web-app Team on Vercel.

A member of the Team first needs to authorize it.

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