Skip to content

auditContext

function auditContext(options?): Elysia<"", {
}, {
}, {
}, {
}, {
}, {
}>;

Defined in: src/adapters/elysia.ts:135

Request-context plugin: resolves the actor / tenant from Elysia’s context (whatever your auth plugin derived) and opens an audit context scope for the handler, so every audit.record() inside it is attributed. Register it after the plugin that derives your user.

app.use(auth).use(auditContext({ actor: ({ user }) => user, tenant: ({ user }) => user?.orgId }));
Parameter Type
options? AuditContextOptions<ElysiaAuditContextCtx>

Elysia<"", { }, { }, { }, { }, { }, { }>