Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
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
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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.