Update rate-limiter.ts

This commit is contained in:
Tanya Byrne
2020-08-18 13:11:10 +01:00
parent 7019b194ee
commit 947a5ee557

View File

@@ -43,7 +43,7 @@ const rateLimiter: RequestHandler = asyncHandler(async (req, res, next) => {
await rateLimiterRedis.consume(req.ip);
} catch (err) {
// If there is no error, rateLimiterRedis promise rejected with number of ms before next request allowed
const secs = Math.round(rejRes.msBeforeNext / 1000) || 1;
const secs = Math.round(err.msBeforeNext / 1000) || 1;
res.set('Retry-After', String(secs));
res.status(429).send('Too Many Requests');
throw new HitRateLimitException(`Too many requests, retry after ${secs}.`);