23 lines
598 B
TypeScript
23 lines
598 B
TypeScript
import { db } from '../db/client';
|
|
import { auditLogs } from '../db/schema';
|
|
|
|
export const writeAuditLog = async (entry: {
|
|
ownerUserId: string;
|
|
action: string;
|
|
targetType: string;
|
|
targetId: string;
|
|
actorDeviceId?: string;
|
|
metadata?: Record<string, unknown>;
|
|
ipAddress?: string;
|
|
}): Promise<void> => {
|
|
await db.insert(auditLogs).values({
|
|
ownerUserId: entry.ownerUserId,
|
|
actorDeviceId: entry.actorDeviceId,
|
|
action: entry.action,
|
|
targetType: entry.targetType,
|
|
targetId: entry.targetId,
|
|
metadata: entry.metadata ?? null,
|
|
ipAddress: entry.ipAddress,
|
|
});
|
|
};
|