This commit is contained in:
jason
2026-04-20 15:49:01 -05:00
parent 381a31d607
commit b98837a72c
46 changed files with 8883 additions and 37 deletions
+29
View File
@@ -0,0 +1,29 @@
import { prisma } from "@/lib/prisma";
export interface AuditInput {
actorId?: string | null;
action: string;
entity: string;
entityId?: string | null;
before?: unknown;
after?: unknown;
ipAddress?: string | null;
}
export async function audit(input: AuditInput): Promise<void> {
try {
await prisma.auditLog.create({
data: {
actorId: input.actorId ?? null,
action: input.action,
entity: input.entity,
entityId: input.entityId ?? null,
before: input.before ? JSON.stringify(input.before) : null,
after: input.after ? JSON.stringify(input.after) : null,
ipAddress: input.ipAddress ?? null,
},
});
} catch (err) {
console.error("[audit] failed to record:", err);
}
}