Writing Lambda Functions
To write the function for our new service, we’re simply going to add another function definition to the index.js file. Name this function popularAnswers. Once you deploy this function, you’ll be able to use the new service we’ve created.
Any additional Lambda functions you want to add to this app should be added to this file as well. As those functions grow, you can break out the logic into other modules in the project, included through the standard Node.js module system.[69]
You might wonder why we aren’t creating a new project to host this function. After all, one of the supposed benefits of microservices is that they’re decoupled from each other. Won’t building all of our Lambda functions into a single project create ...
Get Serverless Single Page Apps now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.