@@ -23,6 +23,8 @@ export default class ServerlessOffline {
2323
2424 #webSocket = null
2525
26+ #alb = null
27+
2628 constructor ( serverless , cliOptions ) {
2729 this . #cliOptions = cliOptions
2830 this . #serverless = serverless
@@ -61,7 +63,7 @@ export default class ServerlessOffline {
6163 async start ( ) {
6264 this . #mergeOptions( )
6365
64- const { httpEvents, lambdas, scheduleEvents, webSocketEvents } =
66+ const { httpEvents, lambdas, scheduleEvents, webSocketEvents, albEvents } =
6567 this . #getEvents( )
6668
6769 // if (lambdas.length > 0) {
@@ -70,6 +72,10 @@ export default class ServerlessOffline {
7072
7173 const eventModules = [ ]
7274
75+ if ( albEvents . length > 0 ) {
76+ eventModules . push ( this . #createAlb( albEvents ) )
77+ }
78+
7379 if ( httpEvents . length > 0 ) {
7480 eventModules . push ( this . #createHttp( httpEvents ) )
7581 }
@@ -99,6 +105,10 @@ export default class ServerlessOffline {
99105 eventModules . push ( this . #lambda. stop ( SERVER_SHUTDOWN_TIMEOUT ) )
100106 }
101107
108+ if ( this . #alb) {
109+ eventModules . push ( this . #alb. stop ( SERVER_SHUTDOWN_TIMEOUT ) )
110+ }
111+
102112 if ( this . #http) {
103113 eventModules . push ( this . #http. stop ( SERVER_SHUTDOWN_TIMEOUT ) )
104114 }
@@ -210,6 +220,18 @@ export default class ServerlessOffline {
210220 return this . #webSocket. start ( )
211221 }
212222
223+ async #createAlb( events , skipStart ) {
224+ const { default : Alb } = await import ( './events/alb/index.js' )
225+
226+ this . #alb = new Alb ( this . #serverless, this . #options, this . #lambda)
227+
228+ this . #alb. create ( events )
229+
230+ if ( ! skipStart ) {
231+ await this . #alb. start ( )
232+ }
233+ }
234+
213235 #mergeOptions( ) {
214236 const {
215237 service : { custom = { } , provider } ,
@@ -264,6 +286,7 @@ export default class ServerlessOffline {
264286 const lambdas = [ ]
265287 const scheduleEvents = [ ]
266288 const webSocketEvents = [ ]
289+ const albEvents = [ ]
267290
268291 const functionKeys = service . getAllFunctions ( )
269292
@@ -277,7 +300,7 @@ export default class ServerlessOffline {
277300 const events = service . getAllEventsInFunction ( functionKey ) || [ ]
278301
279302 events . forEach ( ( event ) => {
280- const { http, httpApi, schedule, websocket } = event
303+ const { http, httpApi, schedule, websocket, alb } = event
281304
282305 if ( ( http || httpApi ) && functionDefinition . handler ) {
283306 const httpEvent = {
@@ -357,6 +380,14 @@ export default class ServerlessOffline {
357380 websocket,
358381 } )
359382 }
383+
384+ if ( alb ) {
385+ albEvents . push ( {
386+ alb,
387+ functionKey,
388+ handler : functionDefinition . handler ,
389+ } )
390+ }
360391 } )
361392 } )
362393
@@ -374,6 +405,7 @@ export default class ServerlessOffline {
374405 }
375406
376407 return {
408+ albEvents,
377409 httpEvents,
378410 lambdas,
379411 scheduleEvents,
0 commit comments