Skip to content

Commit

Permalink
Return json.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloneearth committed May 20, 2018
1 parent 63a5f93 commit 2211396
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ let limiter = new RateLimit({
windowMs: 60000, // 1 minute
max: 20, // limit each IP to 20 requests per windowMs
delayMs: 0, // disable delaying - full speed until the max limit is reached
// handler: function (req, res, /*next*/) {
// if (options.headers) {
// res.setHeader('Retry-After', Math.ceil(options.windowMs / 1000));
// }
// res.format({
// json: function(){
// res.status(500).json({ message: 'Rate Limit'});
// }
// });
// }
handler: function (req, res, /*next*/) {
res.format({
json: function(){
res.status(500).json({ error: 'Too many requests. Limits are 20 requests per minute.'});
}
});
}
});
app.use('/v1/', limiter);

Expand Down

0 comments on commit 2211396

Please sign in to comment.