serverless-aws-lambda
Version:
AWS Application Load Balancer and API Gateway - Lambda dev tool for Serverless. Allows Express synthax in handlers. Supports packaging, local invoking and offline ALB, APG, S3, SNS, SQS, DynamoDB Stream server mocking.
2 lines (1 loc) • 2.88 kB
JavaScript
var m=(e,a,n)=>new Promise((f,g)=>{var h=t=>{try{d(n.next(t))}catch(u){g(u)}},y=t=>{try{d(n.throw(t))}catch(u){g(u)}},d=t=>t.done?f(t.value):Promise.resolve(t.value).then(h,y);d((n=n.apply(e,a)).next())});var C=!1,A=e=>{C=e},O=()=>C,p=(e,a)=>{C&&console.log(`\x1B[${e}m${a}\x1B[0m`)},B=e=>console.log(`\x1B[31m${e}\x1B[0m`),M=e=>p("32",e),U=e=>p("33",e),T=e=>p("36",e),N=e=>p("90",e),Q=e=>p("94",e),$=e=>C?console.log(e):void 0,b={GREEN:M,YELLOW:U,CYAN:T,BR_BLUE:Q,RED:B,GREY:N,setDebug:A,getDebug:O,info:$};var x=["exit","beforeExit","uncaughtException","unhandledRejection","SIGHUP","SIGINT","SIGQUIT","SIGILL","SIGTRAP","SIGABRT","SIGBUS","SIGFPE","SIGUSR1","SIGSEGV","SIGUSR2","SIGTERM"];var E=!1,R=[],H=e=>{if(!E){E=!0;for(let a of R)try{a(e)}catch(n){console.log(n),process.exitCode=1}process.exit()}};x.forEach(e=>{process.on(e,H)});function Y(e){let a=new Set;return e.plugins&&(e.plugins=e.plugins.filter((n,f)=>typeof n!="object"||!n||!("name"in n)?!1:((!n.name||!n.name.length||typeof n.name!="string")&&(n.name="plugin-"+f,b.YELLOW(`Invalid plugin name at index ${f}`)),a.has(n.name)?n.name=n.name+f:a.add(n.name),!0))),function(te){return m(this,arguments,function*({stop:f,lambdas:g,isDeploying:h,isPackaging:y,setEnv:d,stage:t,region:u,esbuild:w,serverless:L,resources:q,getServices:D,setServices:S}){var k,P,I;let s={esbuild:(k=e.esbuild)!=null?k:{},shimRequire:e.shimRequire,includeAwsSdk:e.includeAwsSdk,offline:{staticPath:(P=e.offline)==null?void 0:P.staticPath,port:(I=e.offline)==null?void 0:I.port},afterDeployCallbacks:[],afterPackageCallbacks:[]};e.services&&(yield S(e.services));let c={stop:f,lambdas:g,isDeploying:h,isPackaging:y,setEnv:d,stage:t,region:u,esbuild:w,serverless:L,options:e,config:s,resources:q,getServices:D,setServices:S};if(e.plugins){s.offline.onReady=(i,o)=>m(this,null,function*(){var r;for(let l of e.plugins)if((r=l.offline)!=null&&r.onReady)try{yield l.offline.onReady.call(c,i,o)}catch(G){b.RED(l.name),console.error(G)}}),s.buildCallback=(i,o)=>m(this,null,function*(){for(let r of e.plugins)if(r.buildCallback)try{yield r.buildCallback.call(c,i,o)}catch(l){b.RED(r.name),console.error(l),o||process.exit(1)}});let v=e.plugins.reduce((i,o)=>{var r,l;return(l=(r=o.offline)==null?void 0:r.request)!=null&&l.length&&i.push(...o.offline.request),i},[]);v!=null&&v.length&&(s.offline.request=v.map(i=>(i.callback=i.callback.bind(c),i)));for(let i of e.plugins)if(i.onExit&&R.push(i.onExit.bind(c)),typeof i.afterDeploy=="function"&&s.afterDeployCallbacks.push(i.afterDeploy.bind(c)),typeof i.afterPackage=="function"&&s.afterPackageCallbacks.push(i.afterPackage.bind(c)),i.onInit)try{yield i.onInit.call(c)}catch(o){b.RED(i.name),console.error(o)}}return s.afterDeployCallbacks.length||delete s.afterDeployCallbacks,s.afterPackageCallbacks.length||delete s.afterPackageCallbacks,s})}}var ie=Y;export{ie as default,Y as defineConfig};