-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.d.ts
More file actions
38 lines (31 loc) · 1.15 KB
/
Copy pathglobal.d.ts
File metadata and controls
38 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { IncomingMessage, ServerResponse } from 'http'
export interface AppRequest extends IncomingMessage {
body: any
}
export interface NextFunction {
/**
* Send error to error handler
*/
(err?: any): void
/**
* "Break-out" of a router by calling {next('router')};
* @see {https://expressjs.com/en/guide/using-middleware.html#middleware.router}
*/
(deferToNext: 'router'): void
/**
* "Break-out" of a route by calling {next('route')};
* @see {https://expressjs.com/en/guide/using-middleware.html#middleware.application}
*/
(deferToNext: 'route'): void
}
export interface Test {
use(route: string, ...handlers: RequestHandler[]): void
use(route: ErrorHandler): void
use(...handlers: RequestHandler[]): void
}
// export type NextFunction = () => void
export interface AppResponse extends ServerResponse {}
export type RequestHandler = (req: AppRequest, res: AppResponse, next: NextFunction) => void
export type ErrorHandler = (error: any, req: AppRequest, res: AppResponse, next: NextFunction) => void
export type Handler = RequestHandler | ErrorHandler
export type TMethods = 'ALL' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'