-
-
Notifications
You must be signed in to change notification settings - Fork 797
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on: - #1250 by bayoumymac - https://github.com/tmaslen/serverless-local-alb-example by tmaslen
- Loading branch information
Showing
9 changed files
with
410 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import AlbEventDefinition from './AlbEventDefinition.js' | ||
import HttpServer from './HttpServer.js' | ||
|
||
export default class Alb { | ||
#httpServer = null | ||
|
||
constructor(serverless, options, lambda) { | ||
this.#httpServer = new HttpServer(serverless, options, lambda) | ||
} | ||
|
||
start() { | ||
return this.#httpServer.start() | ||
} | ||
|
||
stop(timeout) { | ||
return this.#httpServer.stop(timeout) | ||
} | ||
|
||
#createEvent(functionKey, rawAlbEventDefinition) { | ||
const albEvent = new AlbEventDefinition(rawAlbEventDefinition) | ||
|
||
this.#httpServer.createRoutes(functionKey, albEvent) | ||
} | ||
|
||
create(events) { | ||
events.forEach(({ functionKey, alb }) => { | ||
this.#createEvent(functionKey, alb) | ||
}) | ||
|
||
this.#httpServer.writeRoutesTerminal() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { assign } = Object | ||
|
||
export default class AlbEventDefinition { | ||
constructor(rawAlbEventDefinition) { | ||
let listenerArn | ||
let priority | ||
let conditions | ||
let rest | ||
|
||
if (typeof rawAlbEventDefinition === 'string') { | ||
;[listenerArn, priority, conditions] = rawAlbEventDefinition.split(' ') | ||
} else { | ||
;({ listenerArn, priority, conditions, ...rest } = rawAlbEventDefinition) | ||
} | ||
|
||
this.listenerArn = listenerArn | ||
this.priority = priority | ||
this.conditions = conditions | ||
|
||
assign(this, rest) | ||
} | ||
} |
Oops, something went wrong.