Repository Public
1import { sql, j } from "./db";2export async function audit(userId: string | null, action: string, entity?: string, entityId?: string, detail: Record<string, unknown> = {}) {3 await sql`INSERT INTO audit_log (user_id, action, entity, entity_id, detail) VALUES (${userId}, ${action}, ${entity ?? null}, ${entityId ?? null}, ${j(detail)})`;4}5