Socket
Socket
Sign inDemoInstall

last-word

Package Overview
Dependencies
4
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    last-word

promise based redis request limiter


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
608 kB
Created
Weekly downloads
 

Readme

Source

Last Word

promise based redis request limiter

Last Word

Build Status

    npm install last-word --save

Usage example

const ms = require('ms');
const lastWord = require('last-word')({
    limit: 3, // number of request before blocked
    timeLimit: ms('1s'), // time in milliseconds when number of requests are cleared
    blockTime: ms('2s'), // block time when
    client: client, // instance of the redis client
    message: 'Limit Reached', // Your custom error message
    Error: YourNewAwesomeError, // Your custom error type
});

app.get('/message', function(req, res, next){
    const key = 'spam_' + req.user.id;
    lastWord(key).then(function() {
        // do your magic here
    }).catch(next);
});

Options that Last Word accepts

NameDescriptionDefault
client(required)instance of the redis clientnull
limitNumber of request before blocked10
timeLimittime in milliseconds when number of requests are clearedms('30s')
blockTimeHow long request key will be blocked, after reaching the limitms('5m')
messageCustom error messageRequest limit reached
ErrorCustom error typeError

Licence

MIT

Name

name is taken from one of the spells of dota 2 silencer hero

Keywords

FAQs

Last updated on 19 Apr 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc