UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.36 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiEventSource=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),apigw=require("../../aws-apigateway"),core_1=require("../../core");class ApiEventSource{constructor(method,path,options){this.method=method,this.path=path,this.options=options;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_apigateway_MethodOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ApiEventSource),error}if(!path.startsWith("/"))throw new Error(`Path must start with "/": ${path}`)}bind(target){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_IFunction(target)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const id=`${core_1.Names.nodeUniqueId(target.node)}:ApiEventSourceA7A86A4F`,stack=core_1.Stack.of(target);let api=stack.node.tryFindChild(id);api||(api=new apigw.RestApi(stack,id,{defaultIntegration:new apigw.LambdaIntegration(target)})),api.root.resourceForPath(this.path).addMethod(this.method,void 0,this.options)}}exports.ApiEventSource=ApiEventSource,_a=JSII_RTTI_SYMBOL_1,ApiEventSource[_a]={fqn:"aws-cdk-lib.aws_lambda_event_sources.ApiEventSource",version:"2.70.0"};