Skip to content

Instantly share code, notes, and snippets.

@ahmedsakr
Last active August 9, 2020 01:05
Show Gist options
  • Save ahmedsakr/faf95eca44bc28eda2d8b7e0f08eca44 to your computer and use it in GitHub Desktop.
Save ahmedsakr/faf95eca44bc28eda2d8b7e0f08eca44 to your computer and use it in GitHub Desktop.
requestFortune lambda for the Fortune Cookie Serverless application
const fortunes = [
"A beautiful, smart, and loving person will be coming into your life.",
"A dubious friend may be an enemy in camouflage.",
"A faithful friend is a strong defense.",
"A feather in the hand is better than a bird in the air.",
"A fresh start will put you on your way.",
"A friend asks only for your time not your money."
];
/**
* The entry point of the Fortune Cookie Lambda.
*
* @param {*} event
*/
export function fortuneHandler(event) {
// returns a random fortune to the request!
return fortunes[parseInt(Math.random() * fortunes.length)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment