1 | import * as express from "express";
|
2 | import App from "./app";
|
3 | import StatusError from "./status-error";
|
4 | export declare const BLOCK_CHAIN = "__block_chain";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export declare abstract class BaseMiddleware {
|
10 | app: App;
|
11 | constructor(app: App);
|
12 | /**
|
13 | * Utility method to generate an error with a status code.
|
14 | * This method should be used instead of the usual throw new Error(msg).
|
15 | * In this way, a proper HTTP status code can be used (for example, 404 or 500),
|
16 | * instead of the default 400.
|
17 | * @param status the http status code to return
|
18 | * @param message the error message
|
19 | * @return a new @type StatusError object
|
20 | */
|
21 | error(status: number, message: string): StatusError;
|
22 | /**
|
23 | * This method is automatically executed by the framework.
|
24 | * @param req the standard express Request object
|
25 | * @param res the standard express Response object
|
26 | * @return to block the middlewares-controller chain, please return `BLOCK_CHAIN`
|
27 | */
|
28 | abstract apply(req: express.Request, res: express.Response): Promise<any>;
|
29 | }
|