simple-ratelimit

1.0.0 • Public • Published

#Simple-ratelimit Intended for login systems

###Usage:

var limit = require('simple-ratelimit');

//Get your last attempt time and number of attempts from your database
var lastAttempt = new Date('2015-2-2');
var attempts = 4;


//Two ways:
if(limit(lastAttempt, attempts)){ ///returns boolean if is rate limit
     //We're being limited
     //You can also add your own logic to add a maximum amount of attempts here.
}


//Or with a callback, containing more info


limit(lastAttempt, attempts, function(limited, requiredWait, elapsed) {
   //limited is a boolean of wether or not we're rate limited
   //requiredWait is the total wait in minutes required since lastAttempt
   //elapsed is the amount of minutes since lastAttempt
   
   //You can also add your own logic to add a maximum amount of attempts here.
});

Readme

Keywords

Package Sidebar

Install

npm i simple-ratelimit

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • richinfante