-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ljacobsson
committed
Jul 25, 2023
1 parent
ad23ea9
commit 39ab04b
Showing
6 changed files
with
84 additions
and
21 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
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 |
---|---|---|
@@ -1,11 +1,26 @@ | ||
export async function routeEvent(event, context, stack, functionSources) { | ||
export async function routeEvent(obj, stack, functionSources) { | ||
try { | ||
const event = obj.event; | ||
const context = obj.context; | ||
process.env = { ...obj.envVars, LOCAL_DEBUG: true }; | ||
|
||
const logicalId = stack.StackResourceSummaries.find(resource => resource.PhysicalResourceId === context.functionName).LogicalResourceId; | ||
const modulePath = functionSources[logicalId].module; | ||
const modulePath = functionSources[logicalId].module; | ||
const module = await import(modulePath); | ||
return await module[functionSources[logicalId].handler](event, context); | ||
} catch (error) { | ||
console.log(error); | ||
return { error: error.message }; | ||
} | ||
} | ||
if (process.argv.length > 3) { | ||
const obj = JSON.parse(process.argv[2]); | ||
const stack = JSON.parse(process.argv[3]); | ||
const functionSources = JSON.parse(process.argv[4]); | ||
routeEvent(obj, stack, functionSources).then((result) => { | ||
const response = typeof result === "string" ? result : JSON.stringify(result, null, 2); | ||
process.send(response || ""); | ||
process.exit(0); | ||
} | ||
); | ||
} |
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