feat: add Redis-backed API rate limits#62
Open
snkk2x-collab wants to merge 2 commits into
Open
Conversation
6 tasks
d7f7718 to
9c9f674
Compare
e4b4e68 to
e9eb058
Compare
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.
Summary
Implements Redis-backed public API rate limiting for #42 using Upstash Redis REST without adding a production SDK dependency.
Changes
rate-limit.middleware.tswith route-specific limits:POST /api/auth/challenge: 10/min per IPPOST /api/auth/*/signed: 5/min per IPPOST /api/events/report: 100/min per API keyGET /api/user/{wallet}/score: 60/min per lender API keyRetry-Afterand readable JSON when the limit is exceeded.UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKENin.env.exampleand README.Validation
pnpm --dir Server exec vitest run src/middleware/__tests__/rate-limit.middleware.test.tspnpm --dir Server exec vitest runpnpm --dir Server exec tsc --noEmit --declaration falseCloses #42