rate-limiter-flexible
Advanced tools
Comparing version 0.22.6 to 0.22.7
@@ -6,2 +6,9 @@ export interface RateLimiterRes { | ||
readonly isFirstInDuration: boolean; | ||
toString(): string; | ||
toJSON(): { | ||
remainingPoints: number; | ||
msBeforeNext: number; | ||
consumedPoints: number; | ||
isFirstInDuration: boolean; | ||
}; | ||
} | ||
@@ -8,0 +15,0 @@ |
{ | ||
"name": "rate-limiter-flexible", | ||
"version": "0.22.6", | ||
"version": "0.22.7", | ||
"description": "Flexible API rate limiter backed by Redis for distributed node.js applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -78,3 +78,3 @@ [![Build Status](https://travis-ci.org/animir/node-rate-limiter-flexible.png)](https://travis-ci.org/animir/node-rate-limiter-flexible) | ||
* [RateLimiterMemcache](https://github.com/animir/node-rate-limiter-flexible/wiki/Memcache) | ||
* [RateLimiterMongo](https://github.com/animir/node-rate-limiter-flexible/wiki/Mongo) | ||
* [RateLimiterMongo](https://github.com/animir/node-rate-limiter-flexible/wiki/Mongo) (with [sharding support](https://github.com/animir/node-rate-limiter-flexible/wiki/Mongo#mongodb-sharding-options)) | ||
* [RateLimiterMySQL](https://github.com/animir/node-rate-limiter-flexible/wiki/MySQL) (support Sequelize and Knex) | ||
@@ -206,2 +206,12 @@ * [RateLimiterPostgres](https://github.com/animir/node-rate-limiter-flexible/wiki/PostgreSQL) (support Sequelize and Knex) | ||
You may want to set next HTTP headers to response: | ||
```javascript | ||
const headers = { | ||
"Retry-After": rateLimiterRes.msBeforeNext / 1000, | ||
"X-RateLimit-Limit": opts.points, | ||
"X-RateLimit-Remaining": rateLimiterRes.remainingPoints, | ||
"X-RateLimit-Reset": new Date(Date.now() + rateLimiterRes.msBeforeNext) | ||
} | ||
``` | ||
### rateLimiter.consume(key, points = 1) | ||
@@ -208,0 +218,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85053
2244
303