Add pagination to audit page

This commit is contained in:
dev
2026-09-10 00:18:56 +03:00
parent 89152295ea
commit 63494f322b
3 changed files with 51 additions and 15 deletions
+3 -2
View File
@@ -607,11 +607,12 @@ app.put('/api/settings', requireAdmin, async (req, res) => {
app.get('/api/audit', requireAdmin, async (req, res) => {
const limit = Math.min(parseInt(req.query.limit, 10) || 100, 1000);
const offset = Math.max(parseInt(req.query.offset, 10) || 0, 0);
const { rows } = await pool.query(
`SELECT a.id, a.action, a.target, a.ip, a.created_at, a.user_id, u.username AS user_name
FROM audit_log a LEFT JOIN users u ON u.id = a.user_id
ORDER BY a.id DESC LIMIT $1`,
[limit]
ORDER BY a.id DESC LIMIT $1 OFFSET $2`,
[limit, offset]
);
res.json(rows);
});