hapi-ratelimiter
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
const Limiter = require('ratelimiter'); | ||
const RequestIp = require('request-ip'); | ||
@@ -37,3 +38,3 @@ const internals = { | ||
if (routeLimit) { | ||
const ipts = [settings.namespace, request.info.remoteAddress, route.path].join(':'); | ||
const ipts = [settings.namespace, RequestIp.getClientIp(request), route.path].join(':'); | ||
const routeLimiter = new Limiter({ | ||
@@ -40,0 +41,0 @@ id: ipts, |
{ | ||
"name": "hapi-ratelimiter", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "A rate limiting plugin for Hapi.", | ||
@@ -26,8 +26,9 @@ "main": "lib/index.js", | ||
"ms": "0.x.x", | ||
"ratelimiter": "2.x.x" | ||
"ratelimiter": "2.x.x", | ||
"request-ip": "^1.2.2" | ||
}, | ||
"devDependencies": { | ||
"code": "2.x.x", | ||
"code": "4.x.x", | ||
"hapi": ">=11", | ||
"lab": "8.x.x" | ||
"lab": "11.x.x" | ||
}, | ||
@@ -34,0 +35,0 @@ "repository": { |
@@ -59,8 +59,8 @@ 'use strict'; | ||
expect(response.statusCode).to.equal(200); | ||
expect(response.result).to.deep.equal({ success: true }); | ||
expect(response.headers).to.include( | ||
expect(response.result).to.equal({ success: true }); | ||
expect(response.headers).to.include([ | ||
'x-ratelimit-limit', | ||
'x-ratelimit-remaining', | ||
'x-ratelimit-reset' | ||
); | ||
]); | ||
@@ -159,7 +159,7 @@ expect(response.headers['x-ratelimit-remaining']).to.equal(1); | ||
expect(response.statusCode).to.equal(200); | ||
expect(response.headers).to.not.include( | ||
expect(response.headers).to.not.include([ | ||
'x-ratelimit-remaining', | ||
'x-ratelimit-limit', | ||
'x-ratelimit-reset' | ||
); | ||
]); | ||
done(); | ||
@@ -204,7 +204,7 @@ }); | ||
expect(response.statusCode).to.equal(501); | ||
expect(response.headers).to.not.include( | ||
expect(response.headers).to.not.include([ | ||
'x-ratelimit-remaining', | ||
'x-ratelimit-limit', | ||
'x-ratelimit-reset' | ||
); | ||
]); | ||
done(); | ||
@@ -211,0 +211,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
12029
231
6
+ Addedrequest-ip@^1.2.2
+ Addedrequest-ip@1.3.0(transitive)