diff --git a/index.js b/index.js index 0778c42..afc6d9d 100644 --- a/index.js +++ b/index.js @@ -14,8 +14,6 @@ app.use(express.urlencoded({ extended: true })); swagger(app); -app.use(limiter); - const PORT = env.PORT; app.listen(PORT, () => { @@ -26,19 +24,23 @@ app.listen(PORT, () => { }); app.use((req, res, next) => { - if (req.url === "/any") { + if (req.url === "/any" || req.url === "/health") { return next(); + } else { + limiter(req, res, (err) => { + if (err) { + return next(err); + } + console.log(` + ${colors.info}Rate Limit:${colors.reset} + ${colors.debug} Limit: ${colors.warning}${req.rateLimit.limit}${colors.reset} + ${colors.debug} Used: ${colors.warning}${req.rateLimit.used}${colors.reset} + ${colors.debug} Remaining: ${colors.warning}${req.rateLimit.remaining}${colors.reset} + ${colors.debug} Reset Time: ${colors.warning}${req.rateLimit.resetTime}${colors.reset} + `); + next(); + }); } - - console.log(` - ${colors.info}Rate Limit:${colors.reset} - ${colors.debug} Limit: ${colors.warning}${req.rateLimit.limit}${colors.reset} - ${colors.debug} Used: ${colors.warning}${req.rateLimit.used}${colors.reset} - ${colors.debug} Remaining: ${colors.warning}${req.rateLimit.remaining}${colors.reset} - ${colors.debug} Reset Time: ${colors.warning}${req.rateLimit.resetTime}${colors.reset} - `); - - next(); }); app.use("/", router);