Node.js
Overview of creating Node.js functions
Getting and publishing a function
The following shows how to get, edit, and pack your template for upload.
After you have downloaded the template project, unzip it and navigate to
./lambda-function
directory.Open the command-line tool and run
npm install
. This will install all initial dependencies.Your entry (main) function will be inside
index.js
file calledexports.handler
.After you did, zip all of the
.js
files andnode_modules
folder. Only production modules are needed so be sure to pack only production modules. You can do that by deleting your currentnod_modules
folder and installing again but using only production flagnpm install --only=prod
. Other files are not needed (can be included depending on your function).Upload zipped file to CodeMash.
For the handler, you have to specify your entry function location. Handler follows such format - fileName.functionName
. Following the structure given in the initial template, the handler would be index.handler
. You can edit any of these parameters for your own function.
Template overview
The following explains how to use provided template to create your own functions.
Last updated