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

rate-limiter-flexible

Package Overview
Dependencies
Maintainers
1
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rate-limiter-flexible - npm Package Compare versions

Comparing version 0.16.3 to 0.16.4

2

package.json
{
"name": "rate-limiter-flexible",
"version": "0.16.3",
"version": "0.16.4",
"description": "Flexible API rate limiter backed by Redis for distributed node.js applications",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -59,3 +59,3 @@ [![Build Status](https://travis-ci.org/animir/node-rate-limiter-flexible.png)](https://travis-ci.org/animir/node-rate-limiter-flexible)

* [RateLimiterMemory](#ratelimitermemory)
* [RateLimiterUnion](#ratelimiterunion) Combine 2 or more limiters to act as single
* [RateLimiterUnion](https://github.com/animir/node-rate-limiter-flexible/wiki/RateLimiterUnion) Combine 2 or more limiters to act as single
* [Express middleware](#express-middleware)

@@ -332,44 +332,2 @@ * [Koa middleware](#koa-middleware)

### RateLimiterUnion
Combine 2 or more rate limiters to act as single
Any rate limiters from this `rate-limiter-flexible` can be united
Useful for authorization, which must be protected from password brute force
For example, not more than once per second and only 5 points per minute
`keyPrefix` is necessary as resolved and rejected results depend on it
```javascript
const limiter1 = new RateLimiterMemory({
keyPrefix: 'limit1',
points: 1,
duration: 1,
});
const limiter2 = new RateLimiterMemory({
keyPrefix: 'limit2',
points: 5,
duration: 60,
});
const rateLimiterUnion = new RateLimiterUnion(limiter1, limiter2);
rateLimiterUnion.consume(remoteAddress)
.then((res) => {
// Returns object with 2 RateLimiterRes objects
res['limit1'].remainingPoints;
res['limit2'].remainingPoints;
})
.catch((rej) => {
/* Returns object with RateLimiterRes objects only for rejected limiters
* For example:
* { limit1: RateLimiterRes { ... } }
*
* It may be Error if you use any limiter without insurance except Memory
* { limit2: Error }
*/
});
```
### Express middleware

@@ -376,0 +334,0 @@

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