UNPKG

829 BTypeScriptView Raw
1import flatten = require('array-flatten');
2export declare type Next<T = void> = (err?: Error | null) => T;
3export declare type RequestHandler<T, U, V = void> = (req: T, res: U, next: Next<V>) => V;
4export declare type ErrorHandler<T, U, V = void> = (err: Error, req: T, res: U, next: Next<V>) => V;
5export declare type Middleware<T, U, V = void> = RequestHandler<T, U, V> | ErrorHandler<T, U, V>;
6export declare type Handler<T, U, V = void> = Middleware<T, U, V> | flatten.NestedArray<Middleware<T, U, V>>;
7/**
8 * Compose an array of middleware handlers into a single handler.
9 */
10export declare function compose<T, U, V = void>(...handlers: Handler<T, U, V>[]): RequestHandler<T, U, V>;
11/**
12 * Wrap middleware handlers.
13 */
14export declare function errors<T, U, V = void>(...handlers: Handler<T, U, V>[]): ErrorHandler<T, U, V>;