Skip to content

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 2, 2023
1 parent 899b43d commit 66bba8c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ const rateLimitError = (() => {

module.exports = rateLimiter
? async (req, res, next) => {
if (req.headers['x-api-key'] === API_KEY) return next()
const { total, reset, remaining } = await rateLimiter.get({
id: req.ipAddress
})

if (!res.writableEnded) {
const _remaining = Math.max(0, remaining - 1)
res.setHeader('X-Rate-Limit-Limit', total)
res.setHeader('X-Rate-Limit-Remaining', _remaining)
res.setHeader('X-Rate-Limit-Reset', reset)
debug(req.ipAddress, { total, remaining: _remaining })
if (req.headers['x-api-key'] === API_KEY) return next()
const { total, reset, remaining } = await rateLimiter.get({
id: req.ipAddress
})

if (!res.writableEnded) {
const _remaining = Math.max(0, remaining - 1)
res.setHeader('X-Rate-Limit-Limit', total)
res.setHeader('X-Rate-Limit-Remaining', _remaining)
res.setHeader('X-Rate-Limit-Reset', reset)
debug(req.ipAddress, { total, remaining: _remaining })
}

return remaining ? next() : next(rateLimitError)
}

return remaining ? next() : next(rateLimitError)
}
: false

0 comments on commit 66bba8c

Please sign in to comment.