lib/audit.js
const db = require('./db');
async function log({ actorType, actorId = null, objectType, objectId = null, eventType, metadata = {} }) {
await db.query(
`INSERT INTO audit_log (actor_type, actor_id, object_type, object_id, event_type, metadata_jsonb)
VALUES ($1, $2, $3, $4, $5, $6)`,
[actorType, actorId, objectType, objectId, eventType, metadata]
);
}
module.exports = { log };