-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
45 lines (36 loc) · 1023 Bytes
/
types.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
import { APIGatewayProxyEvent } from 'aws-lambda';
export type HttpFunction = Controller & {
method?: string;
path?: string;
};
export type HttpResource = Record<string, Handler | Controller> & {
path?: string;
};
type Controller = {
request?: RequestValidation;
middleware?: Handler[] | Record<string, Handler> | (() => Handler[]);
handler: Handler;
};
export type RequestValidation = Record<string, any>;
export interface Middleware<Args extends [] = []> {
(...args: Args): Handler;
}
export interface Handler {
(request: Request, context: Context):
| void
| Partial<Response>
| Promise<void | Partial<Response>>;
}
export type Request = APIGatewayProxyEvent & {
body: any;
method: APIGatewayProxyEvent['httpMethod'];
params: Record<string, string>;
query: APIGatewayProxyEvent['queryStringParameters'];
};
export type Context = Record<string, any>;
export type Response = {
statusCode: number;
body: any;
headers: Record<string, string>;
isBase64Encoded: boolean;
};