Context object passed as the last argument to pipe middleware callbacks. Simpler than HookContext — no returns() needed since you control flow by calling or not calling next().
returns()
next()
hooks.add('execute', async (next, opts, ctx) => { // Modify opts for inner layers ctx.args({ ...opts, headers: { ...opts.headers, Auth: token } }); // Call next to continue the chain, or don't to short-circuit return next(); }); Copy
hooks.add('execute', async (next, opts, ctx) => { // Modify opts for inner layers ctx.args({ ...opts, headers: { ...opts.headers, Auth: token } }); // Call next to continue the chain, or don't to short-circuit return next(); });
Internal
Readonly
Request-scoped state bag shared across hook runs and engine instances.
Replace args for next() and downstream middleware.
ctx.args({ ...opts, timeout: 5000 }); return next(); // next receives modified opts Copy
ctx.args({ ...opts, timeout: 5000 }); return next(); // next receives modified opts
Abort execution with an error.
ctx.fail('Rate limit exceeded'); Copy
ctx.fail('Rate limit exceeded');
Remove this middleware from future runs.
Context object passed as the last argument to pipe middleware callbacks. Simpler than HookContext — no
returns()needed since you control flow by calling or not callingnext().Example