Conversation
Add behavioral tests for the previously untested apiRateLimiter middleware: the 100-requests-per-minute limit and 429 contract for anonymous callers, per-IP and per-user bucket isolation, the skip list for health checks, webhooks, and Better Auth routes, and the disabled mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds behavioral tests for the previously untested
apiRateLimitermiddleware (packages/server/src/middleware/rate-limit.ts). No production code changes.Why
This middleware enforces the general API budget (100 requests/minute) and owns two security-relevant behaviors that had no regression coverage:
Coverage added
{ error: { code: "rate_limited" } }body for anonymous callers./api/health,/api/webhook,/api/webhooks/*,/api/auth, and/api/auth/*are never rate limited, even past the limit.enabled: falsedisables limiting entirely.Tests build a minimal Hono app with the existing
createMemoryApiRateLimitStorage()helper, so they run fully in memory.Validation
vitest run src/middleware/rate-limit.test.ts— 9/9 pass.oxfmt --checkpasses on the new file.oxlintaborts with a Rust allocator panic in this environment, so lint was not run locally.