Skip to content
1 min read · 124 words

Function: runOnion() ​

ts
function runOnion<Ctx, Res>(
   ctx: Ctx,
   use: readonly (ctx: Ctx, next: NextFn) => void | Promise<void>[],
   core: () => Promise<Res>,
onNoNext: () => never): Promise<Res>;

Defined in: src/lib/middleware/run_onion.ts:12

Execute an asynchronous middleware onion around a terminal operation.

A fresh runner is deliberately created for each invocation: middleware runners are single-use. Errors are captured and re-thrown unchanged — including a thrown undefined, which a value-based sentinel would silently swallow — while a chain that stops without invoking its terminal operation is reported through onNoNext.

Type Parameters ​

Type Parameter
Ctx
Res

Parameters ​

ParameterType
ctxCtx
usereadonly (ctx: Ctx, next: NextFn) => void | Promise<void>[]
core() => Promise<Res>
onNoNext() => never

Returns ​

Promise<Res>