Last active
April 3, 2018 13:00
-
-
Save danilop/2ef9a056211a10c68289eaafed583e36 to your computer and use it in GitHub Desktop.
Sample AWS Lambda function showing how to split your business logic from the event handler.
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
"use strict"; | |
console.log('Loading function'); | |
// Your business logic | |
function greetingsFor(name) { | |
console.log('name: ', name); | |
if ((name == undefined) || (name == '')) { | |
name = 'World'; | |
} | |
const greetings = 'Hello ' + name + '!'; | |
console.log('greetings: ', greetings); | |
return greetings; | |
} | |
// Event wrapper | |
exports.handler = async (event, context) => { | |
console.log('Received event:', | |
JSON.stringify(event, null, 2)); | |
return greetingsFor(event.name); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment