import { db } from './db'; import { auditLog } from './schema'; export async function logAudit(params: { userId?: number; action: string; entity?: string; entityId?: number; diff?: Record; ipAddress?: string; }): Promise { await db.insert(auditLog).values({ userId: params.userId ?? null, action: params.action, entity: params.entity ?? null, entityId: params.entityId ?? null, diff: params.diff ?? null, ipAddress: params.ipAddress ?? null }); }