Files
caddy-proxy-manager/src/lib/audit.ts
fuomag9 3be4e1bf7d Rewritten to use drizzle instead of prisma
commit c0894548dac5133bd89da5b68684443748fa2559
Author: fuomag9 <1580624+fuomag9@users.noreply.github.com>
Date:   Fri Nov 7 18:38:30 2025 +0100

    Update config.ts

commit 5a4f1159d2123ada0f698a10011c24720bf6ea6f
Author: fuomag9 <1580624+fuomag9@users.noreply.github.com>
Date:   Fri Nov 7 15:58:13 2025 +0100

    first drizzle rewrite
2025-11-07 19:26:32 +01:00

27 lines
739 B
TypeScript

import db, { nowIso } from "./db";
import { auditEvents } from "./db/schema";
export function logAuditEvent(params: {
userId?: number | null;
action: string;
entityType: string;
entityId?: number | null;
summary?: string | null;
data?: unknown;
}) {
try {
db.insert(auditEvents).values({
userId: params.userId ?? null,
action: params.action,
entityType: params.entityType,
entityId: params.entityId ?? null,
summary: params.summary ?? null,
data: params.data ? JSON.stringify(params.data) : null,
createdAt: nowIso()
}).run();
} catch (error) {
// Log error but don't throw to avoid breaking the main flow
console.error("Failed to log audit event:", error);
}
}