Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/rate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exports.Base = require('./base');
exports.Memory = require('./memory');
exports.Redis = require('./redis');

//
//
// DEFAULTS FOR OPTIONS
// extensibility point
//
Expand Down Expand Up @@ -39,7 +39,7 @@ exports.defaults = function () {
// we zero it here so it doesnt confuse the user

// logic behind this is so for REDIS, we only have to make one increment request (which returns
// the current count), with
// the current count), with
// one roundtrip to the server. Otherwise, we would have to first check what the value is and
// then increment if smaller (which is two roundtrips to the server)
// if someone knows how to do conditionals in REDIS multi transactions, let me know!
Expand All @@ -56,9 +56,9 @@ exports.defaults = function () {
},

onLimitReached: function (req, res, rate, limit, resetTime, next) {
// HTTP code 420 from http://mehack.com/inventing-a-http-response-code-aka-seriously
res.json({error: 'Rate limit exceeded. Check headers for limit information.'}, {status: 420});

// HTTP code 429 based on RFC 6585
res.status(429).json({error: 'Rate limit exceeded. Check headers for limit information.'});
}

};
Expand Down Expand Up @@ -102,7 +102,7 @@ exports.middleware = function recordRate(options) {
} else {

next();

}
};
}
Expand Down