@dotmh/lambda-controller
Version:
A controller to work on AWS Lambda behind API Gateway
63 lines (56 loc) • 1.87 kB
text/typescript
import {APIGatewayProxyEvent, Callback, Context} from 'aws-lambda';
export interface MockCTX {
[key: string]: Context;
}
export const ctx: MockCTX = {
noop: {} as unknown as Context,
};
export interface MockCallbacks {
[key: string]: Callback;
}
export const callback: MockCallbacks = {
noop: () => null,
};
export interface MockEvents {
[key: string]: APIGatewayProxyEvent;
}
export const event: MockEvents = {
valid: {
resource: '/',
path: '/',
httpMethod: 'GET',
isBase64Encoded: false,
headers: {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'cache-control': 'no-cache',
'CloudFront-Forwarded-Proto': 'https',
'CloudFront-Is-Desktop-Viewer': 'true',
'CloudFront-Is-Mobile-Viewer': 'false',
'CloudFront-Is-SmartTV-Viewer': 'false',
'CloudFront-Is-Tablet-Viewer': 'false',
'CloudFront-Viewer-Country': 'GB',
'Host': 'lkht6a2hia.execute-api.eu-west-1.amazonaws.com',
'Postman-Token': '4da311fb-0d8b-474c-b8c7-350ebbafc1fb',
'User-Agent': 'PostmanRuntime/7.4.0',
'Via': '1.1 68126347056de2d05be3dd362ccba987.cloudfront.net (CloudFront)',
'X-Amz-Cf-Id': '0RC8DMEBOlS96tEZc8UqyTuMvKshVdFxHRsJ0APpwlm2_d9Dn7TLeQ==',
'X-Amzn-Trace-Id': 'Root=1-5c8c0ddf-64dce0acf475208acd557696',
'x-api-key': 'JGJ1Ri7AGVTZD17PuOQO9oEZf2XSgyX25bQdT7He',
'X-Forwarded-For': '86.178.79.47, 70.132.20.154',
'X-Forwarded-Port': '443',
'X-Forwarded-Proto': 'https',
},
multiValueHeaders: {},
multiValueQueryStringParameters: null,
stageVariables: null,
queryStringParameters: {
translate:
'컴백 임박’ 모모랜드 연우-주이-혜빈-나윤, 개인 티저 이미지 공개',
},
pathParameters: {
proxy: 'hello',
},
body: null,
} as unknown as APIGatewayProxyEvent,
};