init: AI HR Compliance Assistant
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { AuthRequest } from './auth'
|
||||
import prisma from '../lib/prisma'
|
||||
|
||||
export async function auditLog(
|
||||
req: AuthRequest,
|
||||
action: string,
|
||||
entity: string,
|
||||
entityId?: string,
|
||||
detail?: Record<string, unknown>,
|
||||
) {
|
||||
if (!req.user) return
|
||||
try {
|
||||
await prisma.auditLog.create({
|
||||
data: {
|
||||
orgId: req.user.orgId,
|
||||
userId: req.user.id,
|
||||
action,
|
||||
entity,
|
||||
entityId,
|
||||
detail: detail ? JSON.parse(JSON.stringify(detail)) : undefined,
|
||||
ip: req.ip,
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('Audit log error:', err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user