-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.ts
67 lines (57 loc) · 1.27 KB
/
types.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type {
IncomingMessage,
ServerResponse,
IncomingHttpHeaders,
} from 'http';
import type { Socket, ListenOptions } from 'net';
export type RoutingInfo = {
originalPath: string;
matchedPath?: string;
trailingPath: string;
};
export type RequestHandler = (
req: IncomingMessage,
res: ServerResponse,
routingInfo: RoutingInfo
) => void;
export type RequestRoute = {
path: string;
handler: RequestHandler;
name?: string;
default?: false;
};
export type DefaultRequestRoute = {
default: true;
handler: RequestHandler;
name?: string;
};
export type UpgradeHandler = (
req: IncomingMessage,
socket: Socket,
head: Buffer,
routingInfo: RoutingInfo
) => void;
export type UpgradeRoute = {
path: string;
handler: UpgradeHandler;
name?: string;
default?: false;
};
export type DefaultUpgradeRoute = {
default: true;
handler: UpgradeHandler;
name?: string;
};
export type ServerListenOptions = ListenOptions;
export type HttpRequestInfo = {
method: string;
url: string;
headers: IncomingHttpHeaders;
body?: string;
};
export type HttpConfigs = {
/** The options passed to `http.Server.listen()` method */
listenOptions?: ServerListenOptions;
/** Set to `true` to stop HTTP server listening when app start */
noServer?: boolean;
};