Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Aspnetcoreratelimit | 2,797 | 18 | 58 | a day ago | 20 | June 15, 2021 | 150 | mit | C# | |
ASP.NET Core rate limiting middleware | ||||||||||
Node Rate Limiter Flexible | 2,389 | 68 | 81 | 2 months ago | 146 | September 25, 2022 | 9 | isc | JavaScript | |
Count and limit requests by key with atomic increments in single process or distributed environment. | ||||||||||
Bottleneck | 1,419 | 7,181 | 315 | 3 months ago | 79 | August 03, 2019 | 75 | mit | JavaScript | |
Job scheduler and rate limiter, supports Clustering | ||||||||||
Webapithrottle | 1,119 | 33 | 2 | 3 years ago | 31 | July 31, 2017 | 45 | mit | C# | |
ASP.NET Web API rate limiter for IIS and Owin hosting | ||||||||||
Redis Cell | 1,078 | 24 days ago | 1 | July 31, 2018 | 11 | mit | Rust | |||
A Redis module that provides rate limiting in Redis as a single command. | ||||||||||
Flask Limiter | 953 | 345 | 32 | 3 days ago | 78 | June 07, 2022 | 1 | mit | Python | |
Rate Limiting extension for Flask | ||||||||||
Gubernator | 896 | 3 days ago | 83 | June 07, 2022 | 9 | apache-2.0 | Go | |||
High Performance Rate Limiting MicroService and Library | ||||||||||
Sptdataloader | 625 | 9 days ago | 4 | October 21, 2016 | 2 | apache-2.0 | Objective-C | |||
The HTTP library used by the Spotify iOS client | ||||||||||
Golimit | 589 | 2 years ago | May 31, 2021 | 1 | mit | Go | ||||
Golimit is Uber ringpop based distributed and decentralized rate limiter | ||||||||||
Redis_rate | 573 | 36 | 13 days ago | 33 | October 07, 2021 | 23 | bsd-2-clause | Go | ||
Rate limiting for go-redis |
Rate limit made simple, easy, async. Based on ratelimiter.
$ npm install async-ratelimiter --save
A simple middleware implementation for whatever HTTP server:
'use strict'
const RateLimiter = require('async-ratelimiter')
const { getClientIp } = require('request-ip')
const Redis = require('ioredis')
const rateLimiter = new RateLimiter({
db: new Redis()
})
const apiQuota = async (req, res, next) => {
const clientIp = getClientIp(req)
const limit = await rateLimiter.get({ id: clientIp })
if (!res.writableEnded) {
res.setHeader('X-Rate-Limit-Limit', limit.total)
res.setHeader('X-Rate-Limit-Remaining', Math.max(0, limit.remaining - 1))
res.setHeader('X-Rate-Limit-Reset', limit.reset)
}
return !limit.remaining
? sendFail({
req,
res,
code: HTTPStatus.TOO_MANY_REQUESTS,
message: MESSAGES.RATE_LIMIT_EXCEDEED()
})
: next(req, res)
}
It creates an rate limiter instance.
Required
Type: object
The redis connection instance.
Type: number
Default: 2500
The maximum number of requests within duration
.
Type: number
Default: 3600000
How long keep records of requests in milliseconds.
Type: string
Default: 'limit'
The prefix used for compound the key.
Type: string
The identifier to limit against (typically a user id).
You can pass this value using when you use .get
method as well.
Given an id
, returns a Promise with the status of the limit with the following structure:
total
: max
value.remaining
: number of calls left in current duration
without decreasing current get
.reset
: time since epoch in seconds that the rate limiting period will end (or already ended).Type: string
Default: this.id
The identifier to limit against (typically a user id).
Type: number
Default: this.max
The maximum number of requests within duration
. If provided, it overrides the default max
value. This is useful for custom limits that differ between IDs.
Type: number
Default: this.max
How long keep records of requests in milliseconds. If provided, it overrides the default duration
value.
async-ratelimiter © microlink.io, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.
microlink.io · GitHub microlink.io · Twitter @microlinkhq