mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
feat(auth): user-management audit log (table + record sites + /api/audit endpoint)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ceb24595e6
commit
6af0e97f51
11 files changed
+256
-8
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import { Router } from "express";
|
||||
import type { AuditStore } from "../../data/audit.js";
|
||||
|
||||
export function createAuditRouter(audit: AuditStore): Router {
|
||||
const router = Router();
|
||||
router.get("/", (req, res) => {
|
||||
const limit = clampInt(req.query.limit, 1, 500, 100);
|
||||
const offset = clampInt(req.query.offset, 0, 100_000, 0);
|
||||
res.json({ entries: audit.list(limit, offset) });
|
||||
});
|
||||
return router;
|
||||
}
|
||||
|
||||
function clampInt(v: unknown, min: number, max: number, def: number): number {
|
||||
const n = typeof v === "string" ? parseInt(v, 10) : NaN;
|
||||
if (!Number.isFinite(n)) return def;
|
||||
return Math.min(Math.max(n, min), max);
|
||||
}
|
||||
Reference in new issue
Block a user