Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

last-word

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

last-word

promise based redis request limiter

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 19 Apr 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc