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) • 804 B
JavaScript
import{fork as n}from"child_process";var c=["exit","beforeExit","uncaughtException","unhandledRejection","SIGHUP","SIGINT","SIGQUIT","SIGILL","SIGTRAP","SIGABRT","SIGBUS","SIGFPE","SIGUSR1","SIGSEGV","SIGUSR2","SIGTERM"],r=class{#s;#t=c;#e;constructor(e){this.#e=e??{}}async start(){this.#t.forEach(s=>{process.on(s,()=>{this.stop()})});let e=["aws-lambda"];this.#e.stage&&e.push("-s","dev"),this.#e.watch||e.push("-w","false");let t={...process.env,PORT:this.#e.port};return this.#e.debug&&(t.SLS_DEBUG="*"),this.#s=n(`${process.cwd()}/node_modules/serverless/bin/serverless`,e,{env:t}),this.#s.on("message",({rebuild:s})=>{s&&this.#e.onRebuild?.()}),new Promise((s,h)=>{this.#s.on("message",({port:i,ip:o})=>{i&&s({port:i,ip:o})})})}stop(){return this.#s?.kill()}};export{r as Server,c as exitEvents};