-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
37 lines (34 loc) · 1.03 KB
/
index.d.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
export type OneBlinkAPIHostingRequest<T = void> = {
body: T
headers: Record<string, string | boolean>
method: string
route: string
url: {
host: string
hostname: string
params: { [id: string]: string }
pathname: string
protocol: 'http:' | 'https:'
query: Record<string, string | string[]>
querystring: string
}
}
export interface OneBlinkAPIHostingResponse<T = void> {
readonly headers: OneBlinkAPIHostingRequest['headers']
readonly payload: T
readonly statusCode: number
setHeader(key: string, value: string): OneBlinkAPIHostingResponse<T>
setPayload(payload: T): OneBlinkAPIHostingResponse<T>
setStatusCode(code: number): OneBlinkAPIHostingResponse<T>
}
export type OneBlinkAPIHostingHandlerResult<T> =
| OneBlinkAPIHostingResponse<T>
| T
| number
| void
export type OneBlinkAPIHostingHandler<In = void, Out = void> = (
req: OneBlinkAPIHostingRequest<In>,
res: OneBlinkAPIHostingResponse<Out>,
) =>
| Promise<OneBlinkAPIHostingHandlerResult<Out>>
| OneBlinkAPIHostingHandlerResult<Out>