UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.55 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ApiEventSource=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var apigw=()=>{var tmp=require("../../aws-apigateway");return apigw=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};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(core_1()).UnscopedValidationError(`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.202.0"};