Skip to content

Commit

Permalink
enhance logging for rate limit exceeded events
Browse files Browse the repository at this point in the history
  • Loading branch information
Guru-25 committed Feb 9, 2025
1 parent 48c5863 commit 32d292c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"cookie-parser": "^1.4.6",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-rate-limit": "^7.5.0",
"mongoose": "^8.4.4",
"request": "^2.88.2",
"uuid": "^11.0.3",
"express-rate-limit": "^7.5.0"
"uuid": "^11.0.3"
}
}
3 changes: 2 additions & 1 deletion server/routes/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const limiter = rateLimit({
handler: (request, response) => {
console.warn(`Rate limit exceeded for IP: ${request.ip}`);
if (IS_RECORD_ENABLED) {
sendLogMessage(`Rate limit exceeded for IP: [${request.ip}](https://whatismyipaddress.com/ip/${request.ip})`, process.env.TOPIC4_ID); // Admin
const requestUrl = request.query.url || request.body.url;
sendLogMessage(`Rate limit exceeded for IP: [${request.ip}](https://whatismyipaddress.com/ip/${request.ip}) while accessing URL: ${requestUrl}`, process.env.TOPIC4_ID); // Admin
}
return response.status(429).json({ error: '429 Too Many Requests' });
}
Expand Down

0 comments on commit 32d292c

Please sign in to comment.