21 lines
491 B
TypeScript
21 lines
491 B
TypeScript
import { db } from './db';
|
|
import { auditLog } from './schema';
|
|
|
|
export async function logAudit(params: {
|
|
userId?: number;
|
|
action: string;
|
|
entity?: string;
|
|
entityId?: number;
|
|
diff?: Record<string, unknown>;
|
|
ipAddress?: string;
|
|
}): Promise<void> {
|
|
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
|
|
});
|
|
}
|