-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.d.ts
61 lines (52 loc) · 2.14 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
import * as Koa2Application from 'koa';
import { Application as ExpressApplication } from 'express';
import { Server as RestifyServer } from 'restify';
import { RequestOptions as HttpRequestOptions, IncomingMessage as HttpIncomingMessage, Server as HttpServer } from "http";
type ServerApplication = Koa2Application | ExpressApplication | RestifyServer;
interface ProxyOptions {
framework: 'express' | 'koa' | 'koa2' | 'restify',
binaryMIMETypes?: ReadonlyArray<string>
}
interface APIGatewayRequestIdentity {
secretId?: string
}
interface APIGatewayProxyRequestContext {
serviceId: string,
path: string,
httpMethod: string,
requestId: string,
stage: string,
identity: APIGatewayRequestIdentity,
sourceIp: string,
websocketEnable?: boolean
}
interface APIGatewayProxyRequestEvent {
path: string,
queryString: { [key: string]: string },
httpMethod: string,
headers: { [key: string]: string },
queryStringParameters?: { [key: string]: string },
pathParameters?: { [key: string]: string },
headerParameters?: { [key: string]: string },
stageVariables?: { [key: string]: string },
requestContext: APIGatewayProxyRequestContext,
body: string,
isBase64Encoded?: boolean
}
interface APIGatewayProxyResponse {
statusCode: number,
headers: { [key: string]: string },
body: string,
isBase64Encoded?: boolean
}
declare class Proxy {
constructor(server: HttpServer, options: ProxyOptions);
start(): Promise<HttpServer>;
getRemoteIP(event: APIGatewayProxyRequestEvent): string | null;
buildRequestOptions(event: APIGatewayProxyRequestEvent, context: APIGatewayProxyRequestContext): HttpRequestOptions;
isBinaryContentType(contentType: string): boolean;
sendResponse(error: Error, response: HttpIncomingMessage, context: APIGatewayProxyRequestContext): void;
serveRequest(event: APIGatewayProxyRequestEvent, context: APIGatewayProxyRequestContext): Promise<void>;
}
export declare function createProxy(app: ServerApplication, options: ProxyOptions): Proxy;
export type Handler = (event: APIGatewayProxyRequestEvent, context: APIGatewayProxyRequestContext) => void;