@quiltjs/quilt
Version:
Lightweight, type-safe handler and router abstraction for Node HTTP servers.
29 lines • 1.12 kB
TypeScript
import { Handler } from './Handler.js';
export type ExecuteHandlerHooks<Ctx> = {
onHandlerStart?: (info: {
handler: Handler<any, Ctx, any>;
ctx: Ctx;
}) => void | Promise<void>;
onHandlerSuccess?: (info: {
handler: Handler<any, Ctx, any>;
ctx: Ctx;
durationMs: number;
output: any;
}) => void | Promise<void>;
onHandlerError?: (info: {
handler: Handler<any, Ctx, any>;
ctx: Ctx;
durationMs: number;
error: unknown;
}) => void | Promise<void>;
};
/**
* Executes a handler graph for a given context.
*
* Each handler runs at most once per execution, and its output is cached
* and provided to dependants via the `deps` parameter. The final return
* value is ignored; callers should rely on handler side-effects (for
* example, writing to an HTTP response) or on dependency outputs.
*/
export declare function executeHandler<Ctx, D extends Record<string, Handler<any, Ctx, any>>>(handler: Handler<any, Ctx, D>, ctx: Ctx, hooks?: ExecuteHandlerHooks<Ctx>): Promise<void>;
//# sourceMappingURL=executeHandler.d.ts.map