express-rate-limit 5.4.0 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -177,7 +177,7 @@ Defaults to `false`. Behavior and name will likely change in future releases.
177
177
 
178
178
  Function used to generate keys.
179
179
 
180
- Defaults to req.ip:
180
+ Defaults to req.ip, similar to this:
181
181
 
182
182
  ```js
183
183
  function (req /*, res*/) {
@@ -18,6 +18,11 @@ function RateLimit(options) {
18
18
  skipSuccessfulRequests: false, // Do not count successful requests
19
19
  // allows to create custom keys (by default user IP is used)
20
20
  keyGenerator: function (req /*, res*/) {
21
+ if (!req.ip) {
22
+ throw new Error(
23
+ "express-rate-limit: req.ip is undefined - are you sure you're using express?"
24
+ );
25
+ }
21
26
  return req.ip;
22
27
  },
23
28
  skip: function (/*req, res*/) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-rate-limit",
3
- "version": "5.4.0",
3
+ "version": "5.4.1",
4
4
  "description": "Basic IP rate-limiting middleware for Express. Use to limit repeated requests to public APIs and/or endpoints such as password reset.",
5
5
  "homepage": "https://github.com/nfriedly/express-rate-limit",
6
6
  "author": {