UNPKG

@bitblit/ratchet-epsilon-common

Version:

Tiny adapter to simplify building API gateway Lambda APIS

23 lines 954 B
import { AwsUtil } from '../util/aws-util.js'; import { LambdaEventDetector } from '@bitblit/ratchet-aws/lambda/lambda-event-detector'; export class WebV2Handler { webHandler; constructor(webHandler) { this.webHandler = webHandler; } extractLabel(evt, context) { let rval = this.webHandler.extractLabel(AwsUtil.apiGatewayV2ToApiGatewayV1(evt), context); rval = rval.replace('WEB:', 'WEB2:'); return rval; } handlesEvent(evt) { return LambdaEventDetector.isValidApiGatewayV2WithRequestContextEvent(evt); } async processEvent(evt, context) { const conv = AwsUtil.apiGatewayV2ToApiGatewayV1(evt); const asExtended = Object.assign({}, { parsedBody: null, authorization: null, convertedFromV2Event: true }, conv); const rval = await this.webHandler.openApiLambdaHandler(asExtended, context); return rval; } } //# sourceMappingURL=web-v2-handler.js.map