feat: implement comprehensive audit logging system

This commit is contained in:
nguyenvanbao
2026-02-10 16:42:35 +07:00
parent d440a04618
commit 970fcbac7d
28 changed files with 4783 additions and 2221 deletions

18
utils/requestMeta.js Normal file
View File

@@ -0,0 +1,18 @@
function getClientIp(req) {
const forwarded = req.headers["x-forwarded-for"];
if (forwarded) {
return forwarded.split(",")[0].trim();
}
return req.socket?.remoteAddress || req.connection?.remoteAddress || null;
}
function getUserAgent(req) {
return req.headers["user-agent"] || "";
}
module.exports = {
getClientIp,
getUserAgent,
};