stage 1
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user