edtech / apps /api /src /services /audit.ts
CognxSafeTrack
chore: stabilization, audit fixes and project synchronization
7b0c22b
import { prisma } from './prisma';
import { logger } from '../logger';
export const auditService = {
/**
* Log a sensitive action to the AuditLog table.
*/
async log(params: {
action: string;
actorId?: string;
resourceId?: string;
details?: Record<string, any>;
}) {
try {
await prisma.auditLog.create({
data: {
action: params.action,
actorId: params.actorId,
resourceId: params.resourceId,
details: params.details || {}
}
});
} catch (err) {
logger.error({ err, params }, '[AUDIT] Failed to save audit log');
}
}
};