import type { Context } from './context.ts'; /** Route handler: the returned value works as sugar (§8). */ export type Handler = (c: Context) => unknown | Promise; /** Onion middleware. */ export type Middleware = (c: Context, next: () => Promise) => unknown | Promise; /** A regular lifecycle hook. */ export type Hook = (c: Context) => unknown | Promise; /** An error handling hook. */ export type ErrorHook = (err: unknown, c: Context) => unknown | Promise; /** Stages that run before the handler. */ export declare const BEFORE_STAGES: readonly ['onRequest', 'preParsing', 'preValidation', 'preHandler']; /** Stages that run after (always executed). */ export declare const AFTER_STAGES: readonly ['preSerialization', 'onSend']; /** All lifecycle stages. */ export declare const ALL_STAGES: readonly ["onRequest", "preParsing", "preValidation", "preHandler", "preSerialization", "onSend", "onResponse", "onError", "onTimeout", "onAbort"]; /** A lifecycle stage name. */ export type StageName = (typeof ALL_STAGES)[number]; /** A stage before the handler. */ export type BeforeStage = (typeof BEFORE_STAGES)[number]; /** A middleware or hook together with the path prefix it is mounted on. */ export interface Scoped { prefix: string; fn: T; } /** A route before its chain is precompiled. */ export interface RouteDefinition { path: string; handler: Handler; middleware?: Middleware[]; hooks?: Partial>>; } /** The precompiled chain of a single route leaf. */ export type Chain = { handler: Handler; middleware: Middleware[]; onError: ErrorHook[]; /** Precomputed at buildChain: any non-empty "before" stage (fast-path skips the loop). */ hasBefore: boolean; } & { [K in Exclude]: Hook[]; }; /** Whether a middleware/hook prefix matches the route path. */ export declare function prefixMatches(prefix: string, path: string): boolean; /** Precompile the chain for one route: globals (by prefix) plus route-level ones. */ export declare function buildChain(route: RouteDefinition, globalMiddleware: Array>, globalHooks: Record>>): Chain; /** Run the "after" hooks: all of them run (they may refine the response); errors bubble. */ export declare function runAfterHooks(hooks: Hook[], c: Context): Promise; /** Core: "before" hooks → onion; exceptions → onError. Fills in c (does not write). */ export declare function runCore(chain: Chain, c: Context): Promise; /** Race the core against a timeout. On timeout: abort the signal → onTimeout → 504, * then latch the response. */ export declare function withTimeout(chain: Chain, c: Context, ms: number, controller: AbortController): Promise; //# sourceMappingURL=pipeline.d.ts.map