UNPKG

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) 1.3 kB
"use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var d=(s,e)=>{for(var i in e)o(s,i,{get:e[i],enumerable:!0})},g=(s,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of f(e))!a.call(s,r)&&r!==i&&o(s,r,{get:()=>e[r],enumerable:!(t=l(e,r))||t.enumerable});return s};var I=s=>g(o({},"__esModule",{value:!0}),s);var G={};d(G,{Server:()=>n,exitEvents:()=>h});module.exports=I(G);var p=require("child_process"),h=["exit","beforeExit","uncaughtException","unhandledRejection","SIGHUP","SIGINT","SIGQUIT","SIGILL","SIGTRAP","SIGABRT","SIGBUS","SIGFPE","SIGUSR1","SIGSEGV","SIGUSR2","SIGTERM"],n=class{#s;#t=h;#e;constructor(e){this.#e=e??{}}async start(){this.#t.forEach(t=>{process.on(t,()=>{this.stop()})});let e=["aws-lambda"];this.#e.stage&&e.push("-s","dev"),this.#e.watch||e.push("-w","false");let i={...process.env,PORT:this.#e.port};return this.#e.debug&&(i.SLS_DEBUG="*"),this.#s=(0,p.fork)(`${process.cwd()}/node_modules/serverless/bin/serverless`,e,{env:i}),this.#s.on("message",({rebuild:t})=>{t&&this.#e.onRebuild?.()}),new Promise((t,r)=>{this.#s.on("message",({port:c,ip:S})=>{c&&t({port:c,ip:S})})})}stop(){return this.#s?.kill()}};0&&(module.exports={Server,exitEvents});