1 | import { APIGatewayEvent, Context, Callback, APIGatewayEventIdentity } from 'aws-lambda';
|
2 | import { ApiResponse, ResponseParameters, RedirectParameters, ErrorParameters, CustomParameters } from '../shared';
|
3 | export declare function api<T = any>(customHandler: (props: ApiSignature<T>) => any): (event: APIGatewayEvent, context: Context, callback: Callback) => any;
|
4 | export interface ApiSignature<T = any> {
|
5 | event: APIGatewayEvent;
|
6 | body: T;
|
7 | websocket: WebsocketRequest;
|
8 | path: {
|
9 | [name: string]: string;
|
10 | };
|
11 | query: {
|
12 | [name: string]: string;
|
13 | };
|
14 | headers: {
|
15 | [name: string]: string;
|
16 | };
|
17 | testRequest: boolean;
|
18 | auth: any;
|
19 | success(params?: ResponseParameters): ApiResponse;
|
20 | invalid(params?: ResponseParameters): ApiResponse;
|
21 | notFound(params?: ResponseParameters): ApiResponse;
|
22 | notAuthorized(params?: ResponseParameters): ApiResponse;
|
23 | redirect(params: RedirectParameters): ApiResponse;
|
24 | error(params?: ErrorParameters): ApiResponse;
|
25 | custom(params: CustomParameters): ApiResponse;
|
26 | }
|
27 | export interface WebsocketRequest {
|
28 | accountId: string;
|
29 | apiId: string;
|
30 | connectedAt?: number;
|
31 | connectionId?: string;
|
32 | domainName?: string;
|
33 | domainPrefix?: string;
|
34 | eventType?: string;
|
35 | extendedRequestId?: string;
|
36 | protocol: string;
|
37 | httpMethod: string;
|
38 | identity: APIGatewayEventIdentity;
|
39 | messageDirection?: string;
|
40 | messageId?: string | null;
|
41 | path: string;
|
42 | stage: string;
|
43 | requestId: string;
|
44 | requestTime?: string;
|
45 | requestTimeEpoch: number;
|
46 | resourceId: string;
|
47 | resourcePath: string;
|
48 | routeKey?: string;
|
49 | }
|