fix(rate limits): Testing recursive rate limits

This commit is contained in:
Chris Troutner
2021-02-24 14:14:36 -08:00
parent f52a04a337
commit 44ce5f2aa9
3 changed files with 16 additions and 13 deletions
+8 -5
View File
@@ -129,9 +129,17 @@ class RateLimits {
const resource = _this.getResource(req.url)
wlogger.debug(`resource: ${resource}`)
// Key will be the JWT ID if it exists, otherwise the IP address of the caller.
let key = userId || req.ip
res.locals.key = key // Feedback for tests.
// For internal calls that make a lot of internal calls, like
// hydrateUtxoDetails(), the origin of the caller will be passed in
// via the POST body.
if (req.body && req.body.ip) {
key = req.body.ip
}
// const pointsToConsume = userId ? 1 : 30
decoded.resource = resource
let pointsToConsume = _this.calcPoints(decoded)
@@ -147,11 +155,6 @@ class RateLimits {
wlogger.info(`origin: ${origin}`)
const bodyOrigin = req.body.origin
if (bodyOrigin) {
console.log(`bodyOrigin: ${bodyOrigin}`)
}
// If the request originates from one of the approved wallet apps, then
// apply paid-access rate limits.
// console.log(`origin: ${JSON.stringify(origin, null, 2)}`)