This example is based upon the example template inside this node-lambda package https://www.npmjs.com/package/node-lambda.
The aim of this repo and effort is to understand and uncover the workings of using serverless. There are many layers of technology used to create even the most simple mircoservice, you may find that you can jump ahead and find a template, or like myself, find a sea of solutions and feel unsure as to what is the best for you.
In this persuit, please feel free to message me and share your ideas, learnings.
The core construct of Lambda at its entry point consists of a function. exports.handler = function (event, context, callback) {}
event - This parameter should consist of the data coming in to the function such as, API Method, Parameters. The API Gateway has a template that can unravel the incoming request into the event format (see event.json for a clear example of how your request will be recieved by Lambda).
context - The context object recieved contains information about the lambda function. It appears to have one method, getRemainingTimeInMillis() and other useful data such as evn type and data usage.
callback - in many examples this has been removed from the initial construct, which suggests the use of a callback is not widely used as best practice. I'll update this as I find out more about the behaviours of Lambda as a tool for serving your awesome microservice or API.
... to be added soon.
See the commands available in the package json, to test locally, build and deploy.
https://www.npmjs.com/package/node-lambda
https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html