UNPKG

@ne1410s/xprest

Version:
30 lines (29 loc) 1.16 kB
declare type XHeaders = Record<string, string | string[] | number>; export interface MdwIn<TReq> { data: TReq; requestHeaders: XHeaders; responseHeaders: XHeaders; status: number; } export declare class PipelineError extends Error { readonly status: number; readonly data: any; constructor(status: number, data: any, message?: string); } /** * Http middleware, serving as either the single 'main' handler; returning an * object or one of many 'passive' handlers; not returning anything. A pipeline * can be entirely terminated (prior to the main handler) by throwing an error. * A PipelineError can be used to provide response status and data. * @throws PipelineError. */ export declare type Mdw<TReq, TRes> = (sub: MdwIn<TReq>) => TRes | void; /** * Http passive middleware, which may alter headers and response code - but only * prior to the main handler. A pipeline can be entirely terminated (prior to * the main handler) by throwing an error. A PipelineError can be used to * provide response status and data. * @throws PipelineError. */ export declare type PassiveMdw<TReq> = (sub: MdwIn<TReq>) => void; export {};