runWithAuditContext
function runWithAuditContext<T>(scope, fn): T;Defined in: src/context.ts:52
Run fn inside a scope. Nested scopes inherit and override the outer one
(context keys merge).
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scope |
AuditScope |
fn |
() => T |
Returns
Section titled “Returns”T
Example
Section titled “Example”import { runWithAuditContext } from "@xtandard/audit/context";
await runWithAuditContext({ actor: { id: user.id }, tenant: user.orgId }, () => audit.record({ action: "invoice.paid", metadata: { invoiceId } }),);