Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
strict-rate-limiter
Advanced tools
Rate limiter backed by redis with strict concurrency rules for scalable applications
Rate limiter backed by redis with strict concurrency rules for scalable applications
Suitable for cloud applications with multi-node and/or cluster infrastructure.
To keep the limiter up-to-date across multiple workers or nodes, it uses a lock mechanism to throttle the connection while the previous connection is not yet dispatched and the limiter is saved to the redis database. The lock mechanism throttles only those concurrent connections coming from the same origin (identified by the ID).
$ npm install strict-rate-limiter
var redisClient = redis.createClient();
var id = req.apiKey;
// allow 100 request / 60s
limiters[id] = new RateLimiter({
id: id,
limit: 100, // 100 tokens
duration: 60000 // 60s duration
}, redisClient);
limiters[id].get(function(err, limit, remaining, reset) {
if (err) {
return next(err);
}
res.setHeader('X-RateLimit-Limit', limit);
res.setHeader('X-RateLimit-Remaining', remaining);
res.setHeader('X-RateLimit-Reset', Math.floor(reset / 1000));
if (remaining >= 0) {
// allowed, call next middleware
next();
} else {
// limit exceeded
res.setHeader('Retry-After', Math.floor((reset - new Date()) / 1000));
res.statusCode = 429;
res.end('Rate limit exceeded.');
}
});
id
Unique identifier (API key, IP address or user ID)limit
Number of tokensduration
Duration in millisecondsnamespace
(optional) Overwrite key prefix
(defaults to ratelimit:
)
(actual redis key is namespace + id
)$ npm test
MIT
FAQs
Rate limiter backed by redis with strict concurrency rules for scalable applications
The npm package strict-rate-limiter receives a total of 0 weekly downloads. As such, strict-rate-limiter popularity was classified as not popular.
We found that strict-rate-limiter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.