SPB Git
483 B · 6 lines typescript
1import { db, schema } from "@/db";2/** Append-only audit entry (DB trigger forbids UPDATE/DELETE). */3export async function audit(actor: { id?: string | null; name: string }, action: string, entity?: { type: string; id: string }, details: Record<string, unknown> = {}, ip?: string | null) {4  await db.insert(schema.auditLog).values({ actorId: actor.id ?? null, actor: actor.name, action, entityType: entity?.type ?? null, entityId: entity?.id ?? null, details, ip: ip ?? null });5}6
Files · 5c3b8a5623be24a7ead64d17000f0a8e2f1542cc
Menu

Theme