improve: enhance in-memory rate limiter with headers and safety#700
Open
Shreya-nipunge wants to merge 1 commit into
Open
improve: enhance in-memory rate limiter with headers and safety#700Shreya-nipunge wants to merge 1 commit into
Shreya-nipunge wants to merge 1 commit into
Conversation
|
@Shreya-nipunge is attempting to deploy a commit to the durdana3105's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
this branch have merge conflicts please resolve it |
026c621 to
9a7b076
Compare
Contributor
Author
|
Hi @durdana3105 , The merge conflicts have been resolved and the branch is now up to date with the latest upstream changes. The current CI failure appears to occur during Thank you. |
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.
Description
This PR improves the existing in-memory rate limiter by adding production-grade API enhancements such as standard rate-limit headers, memory safety improvements, and better documentation while keeping the lightweight architecture unchanged.
The goal is to enhance usability and robustness without introducing external dependencies or increasing system complexity.
Related Issue
Fixes #682
Changes Made
Added standard rate-limit response headers:
X-RateLimit-LimitX-RateLimit-RemainingX-RateLimit-ResetAdded memory safety improvements:
Improved inline documentation explaining design trade-offs (in-memory vs distributed systems)
Ensured compatibility for both authenticated (
req.user.id) and unauthenticated (req.ip) requestsClarified that in-memory reset behavior on server restart is an intentional design trade-off
Design Decision
This rate limiter is intentionally implemented using an in-memory
Mapto ensure high performance and zero external infrastructure dependency. This approach keeps latency minimal and simplifies local development and deployment.The limitation of state reset on server restart and per-instance behavior is acknowledged as an accepted trade-off for this design.
Impact
Testing