redis-rate-limiter
Advanced tools
Comparing version 1.0.3 to 1.0.4
var assert = require('assert'); | ||
var moment = require('moment'); | ||
var ip = require('ip'); | ||
@@ -40,10 +39,6 @@ exports.canonical = function(opts) { | ||
var keyShorthands = { | ||
'ip': function(req) { | ||
return req.connection.remoteAddress; | ||
}, | ||
'ip/32': function (req) { | ||
return ip.mask(req.connection.remoteAddress, '255.255.255.0') + '/32'; | ||
} | ||
}; |
{ | ||
"name": "redis-rate-limiter", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Rate-limit any operation, backed by Redis", | ||
@@ -10,17 +10,18 @@ "author": "Tabcorp Digital Team", | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha" | ||
"lint": "require-lint", | ||
"test": "mocha" | ||
}, | ||
"dependencies": { | ||
"ip": "~1.1.2", | ||
"moment": "~2.12.0" | ||
"moment": "~2.14.1" | ||
}, | ||
"devDependencies": { | ||
"async": "~1.5.2", | ||
"express": "~4.13.4", | ||
"lodash": "~4.6.1", | ||
"mocha": "~2.4.5", | ||
"async": "~2.0.1", | ||
"express": "~4.14.0", | ||
"lodash": "~4.15.0", | ||
"mocha": "~3.0.2", | ||
"redis": "~2.6.0-0", | ||
"should": "~8.3.0", | ||
"supertest": "~1.2.0" | ||
"require-lint": "^1.1.1", | ||
"should": "~11.1.0", | ||
"supertest": "~2.0.0" | ||
} | ||
} |
@@ -73,17 +73,4 @@ # redis-rate-limiter | ||
The key is how requests are grouped for rate-limiting. | ||
Typically, this would be a user ID, a type of operation... | ||
There are several helpers built-in: | ||
Typically, this would be a user ID, a type of operation. | ||
```js | ||
// identify users by IP | ||
key: 'ip' | ||
// identify users by their IP network (255.255.255.0 mask) | ||
key: 'ip/32' | ||
// identify users by the X-Forwarded-For header | ||
// careful: this is just an HTTP header and can easily be spoofed | ||
key: 'x-forwarded-for' | ||
``` | ||
You can also specify any custom function: | ||
@@ -102,2 +89,8 @@ | ||
You can also use the built-in `ip` shorthand, which gets the remote address from an HTTP request. | ||
```js | ||
key: 'ip' | ||
``` | ||
### `window` | ||
@@ -188,3 +181,2 @@ | ||
); | ||
``` |
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
1
7799
8
85
180
+ Addedmoment@2.14.1(transitive)
- Removedip@~1.1.2
- Removedip@1.1.9(transitive)
- Removedmoment@2.12.0(transitive)
Updatedmoment@~2.14.1