-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.d.ts
64 lines (48 loc) · 3.6 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
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
export namespace OpenApi {
export interface ApiOptions {
requestMiddleware?: ((event: object, context: object) => Promise<unknown>) | (() => unknown) | undefined;
responseMiddleware?: ((request: object, context: object) => Promise<unknown>) | (() => unknown) | undefined;
errorMiddleware?: ((event: object, error: object) => Promise<unknown>) | (() => unknown) | undefined;
}
export interface HttpMethodOptions {
rawBody?: boolean | undefined;
}
export interface HttpResponse {
statusCode?: number | undefined;
headers?: object | undefined;
body?: (object | string) | undefined;
}
}
export default class OpenApi {
constructor(options: OpenApi.ApiOptions, overrideLogger?: () => void);
setAuthorizer(authorizerFunc: (req?: unknown) => Promise<unknown>): void;
onEvent(onEventFunc: (req?: unknown) => Promise<unknown>): void;
onSchedule(onScheduleFunc: (req?: unknown) => Promise<unknown>): void;
/**
* @returns The the Path map { [path]: { [method]: {metadata} } } for discovery usage.
*/
getPathMap(): Record<string, Record<string, unknown>>;
/**
* @returns The matched route based on the method and the specified path.
*/
resolveRoute(method: string, path: string): string;
head(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
head(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
get(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
get(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
post(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
post(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
put(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
put(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
patch(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
patch(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
query(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
query(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
delete(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
delete(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
options(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
options(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
any(route: string, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
any(route: string, options: OpenApi.HttpMethodOptions, handler: (req?: object) => (OpenApi.HttpResponse | Promise<OpenApi.HttpResponse>)): void;
handler(event: object, context: object): Promise<unknown>;
}