1 | import {
|
2 | APIGatewayEventDefaultAuthorizerContext,
|
3 | APIGatewayEventRequestContextWithAuthorizer,
|
4 | } from "../common/api-gateway";
|
5 | import { Callback, Handler } from "../handler";
|
6 |
|
7 | export type APIGatewayProxyHandler = Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
|
8 | export type APIGatewayProxyCallback = Callback<APIGatewayProxyResult>;
|
9 |
|
10 | export type APIGatewayProxyEvent = APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>;
|
11 |
|
12 | export type APIGatewayProxyWithLambdaAuthorizerHandler<TAuthorizerContext> =
|
13 | Handler<APIGatewayProxyWithLambdaAuthorizerEvent<TAuthorizerContext>, APIGatewayProxyResult>;
|
14 |
|
15 | export type APIGatewayProxyWithCognitoAuthorizerHandler =
|
16 | Handler<APIGatewayProxyWithCognitoAuthorizerEvent, APIGatewayProxyResult>;
|
17 |
|
18 | export type APIGatewayProxyWithLambdaAuthorizerEvent<TAuthorizerContext> =
|
19 | APIGatewayProxyEventBase<APIGatewayEventLambdaAuthorizerContext<TAuthorizerContext>>;
|
20 |
|
21 | export type APIGatewayProxyWithLambdaAuthorizerEventRequestContext<TAuthorizerContext> =
|
22 | APIGatewayEventRequestContextWithAuthorizer<APIGatewayEventLambdaAuthorizerContext<TAuthorizerContext>>;
|
23 |
|
24 |
|
25 |
|
26 | export type APIGatewayEventLambdaAuthorizerContext<TAuthorizerContext> = {
|
27 | [P in keyof TAuthorizerContext]: TAuthorizerContext[P] extends null ? null : string;
|
28 | } & {
|
29 | principalId: string;
|
30 | integrationLatency: number;
|
31 | };
|
32 |
|
33 | export type APIGatewayProxyWithCognitoAuthorizerEvent = APIGatewayProxyEventBase<APIGatewayProxyCognitoAuthorizer>;
|
34 |
|
35 |
|
36 | export interface APIGatewayProxyCognitoAuthorizer {
|
37 | claims: {
|
38 | [name: string]: string;
|
39 | };
|
40 | }
|
41 |
|
42 | export interface APIGatewayProxyEventBase<TAuthorizerContext> {
|
43 | body: string | null;
|
44 | headers: { [name: string]: string };
|
45 | multiValueHeaders: { [name: string]: string[] };
|
46 | httpMethod: string;
|
47 | isBase64Encoded: boolean;
|
48 | path: string;
|
49 | pathParameters: { [name: string]: string } | null;
|
50 | queryStringParameters: { [name: string]: string } | null;
|
51 | multiValueQueryStringParameters: { [name: string]: string[] } | null;
|
52 | stageVariables: { [name: string]: string } | null;
|
53 | requestContext: APIGatewayEventRequestContextWithAuthorizer<TAuthorizerContext>;
|
54 | resource: string;
|
55 | }
|
56 |
|
57 | export interface APIGatewayProxyResult {
|
58 | statusCode: number;
|
59 | headers?: {
|
60 | [header: string]: boolean | number | string;
|
61 | };
|
62 | multiValueHeaders?: {
|
63 | [header: string]: Array<boolean | number | string>;
|
64 | };
|
65 | body: string;
|
66 | isBase64Encoded?: boolean;
|
67 | }
|
68 |
|
69 |
|
70 | export type ProxyHandler = APIGatewayProxyHandler;
|
71 | export type ProxyCallback = APIGatewayProxyCallback;
|
72 | export type APIGatewayEvent = APIGatewayProxyEvent;
|
73 | export type ProxyResult = APIGatewayProxyResult;
|