async-middleware
Version:
Wrap an asynchronous middleware (or handler) function for Express, Connect, router, etc.
12 lines (11 loc) • 390 B
TypeScript
export interface NextFunction {
(err?: Error): void;
}
export interface Handler<T, U> {
(req: T, res: U, next: NextFunction): any;
}
export interface ErrorHandler<T, U> {
(err: Error, req: T, res: U, next: NextFunction): any;
}
export declare function wrap<T, U>(fn: Handler<T, U>): Handler<T, U>;
export declare function wrap<T, U>(fn: ErrorHandler<T, U>): ErrorHandler<T, U>;