hyacinth
v0.0.5
Published
Rate limiter that uses the Token Bucket algorithm
Downloads
11
Maintainers
Readme
Hyacinth
Actually, it's a Token Bouquet rate limiter
Installation
When its on npm...
npm install hyacinth
Usage
var TokenBucket = require('hyacinth');
var rateLimiter = new TokenBucket({
redis: redisClient
});
rateLimiter.rateLimit(testKey, 10, 250, 240).then(function(tokensRemaining){
// Negative number indicates the tokens remaining but limited
// as the cost was higher than those remaining
if(data < 0) return requestDenied();
requestApproved();
});