import { all, get, run } from "../db/connection.js"; export async function log({ actor, action, target = "", detail = "" }) { await run(`INSERT INTO audit_logs (actor, action, target, detail) VALUES (?, ?, ?, ?)`, [ actor, action, target, detail, ]); } export async function recent(limit = 50) { return all(`SELECT * FROM audit_logs ORDER BY id DESC LIMIT ?`, [limit]); } export async function count() { const row = await get(`SELECT COUNT(*) AS c FROM audit_logs`); return Number(row?.c ?? 0); }