forked from honojs/node-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
82 lines (70 loc) · 1.88 KB
/
types.ts
File metadata and controls
82 lines (70 loc) · 1.88 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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import type { WebSocketServer } from 'ws'
import type {
createServer,
IncomingMessage,
Server,
ServerOptions as HttpServerOptions,
ServerResponse as HttpServerResponse,
} from 'node:http'
import type {
createSecureServer as createSecureHttp2Server,
createServer as createHttp2Server,
Http2ServerRequest,
Http2Server,
Http2ServerResponse,
Http2SecureServer,
SecureServerOptions as SecureHttp2ServerOptions,
ServerOptions as Http2ServerOptions,
} from 'node:http2'
import type {
createServer as createHttpsServer,
ServerOptions as HttpsServerOptions,
} from 'node:https'
export type HttpBindings = {
incoming: IncomingMessage
outgoing: HttpServerResponse
}
export type Http2Bindings = {
incoming: Http2ServerRequest
outgoing: Http2ServerResponse
}
export type FetchCallback = (
request: Request,
env: HttpBindings | Http2Bindings
) => Promise<unknown> | unknown
export type NextHandlerOption = {
fetch: FetchCallback
}
export type ServerType = Server | Http2Server | Http2SecureServer
type createHttpOptions = {
serverOptions?: HttpServerOptions
createServer?: typeof createServer
}
type createHttpsOptions = {
serverOptions?: HttpsServerOptions
createServer?: typeof createHttpsServer
}
type createHttp2Options = {
serverOptions?: Http2ServerOptions
createServer?: typeof createHttp2Server
}
type createSecureHttp2Options = {
serverOptions?: SecureHttp2ServerOptions
createServer?: typeof createSecureHttp2Server
}
export type ServerOptions =
| createHttpOptions
| createHttpsOptions
| createHttp2Options
| createSecureHttp2Options
export type Options = {
fetch: FetchCallback
overrideGlobalObjects?: boolean
autoCleanupIncoming?: boolean
port?: number
hostname?: string
websocket?: {
server: WebSocketServer
}
} & ServerOptions
export type CustomErrorHandler = (err: unknown) => void | Response | Promise<void | Response>