feat: ratelimits (#2073)

* feat: rate limits

* ip
This commit is contained in:
Philip Okugbe
2026-03-30 15:38:44 +01:00
committed by GitHub
parent a062f7a165
commit c180d0e487
9 changed files with 104 additions and 33 deletions
+6 -14
View File
@@ -50,20 +50,12 @@ export function createPinoConfig(): Params {
},
},
serializers: {
req: (req) => {
const forwardedFor = req.headers?.['x-forwarded-for'];
const ip =
req.headers?.['cf-connecting-ip'] ||
(typeof forwardedFor === 'string' ? forwardedFor.split(',')[0]?.trim() : undefined) ||
req.remoteAddress;
return {
method: req.method,
url: req.url,
ip,
userAgent: req.headers?.['user-agent'],
};
},
req: (req) => ({
method: req.method,
url: req.url,
ip: req.ip || req.remoteAddress,
userAgent: req.headers?.['user-agent'],
}),
res: (res) => ({
statusCode: res.statusCode,
}),