NodeJS API Scaffolding

If you’re looking to launch an API using NodeJS, here is a very handy scaffolded application starting point:

What you get:

  • Logging
  • JWT Authentication
  • MongoDB (via Mongoose) modeling
  • md-seed migration and seed management for MongoDB
  • Docker & Docker-Compose provisioning
  • dotenv environment variable management
  • APIDOC automatically generated documentation

Check out the repository for a quick rundown and getting-started guide, and if you have any questions or issues please don’t hesitate to ask.

Major thank you to danielfsousa and his boilerplate for the starting point of this scaffolding.

Email notification on new artifact build using AWS Lambda


  1. You have installed and configured AWS CLI
  2. You have a third party mail service setup already (we use mailgun for this example).

The entire process for this simple effort requires a handful of steps:

  1. Install SAM Local
  2. Define your Lambda in AWS Console (can also do so using CLI)
  3. Write your function!

SAM Local

First, let’s install SAM Local.

SAM Local is an amazing tool written by Paul Maddox from the AWS team that allows you to build and test Lambda functions locally.

npm install -g aws-sam-local

Later, we’ll use event.json as a sample file we test our function with, so build that quickly; for example:

Define your Lambda in AWS Console

You can easily simplify this process using the aws cli but for this we’ll simply share a simple step-by-step that outlines the function for a first time developer.

  1. Create a New Function
    1. Author from scratch
    2. Name it something you’ll recognize later
    3. Runtime Node.js 6.1.0
    4. Role Choose an Existing Role
    5. Select a Role that has policies to execute Lambda functions, and access SSM Parameter Store (and anything else your function will be doing).
  2. Function Designer
    1. Select S3 from the left column
    2. Scroll down to Configure Triggers
    3. Select an appropriate bucket, and then make sure you have the trigger enabled.

Write your Function

Once complete, we’ll be zipping our node_modules and index.js file and uploading them to the Function via the console.

Testing Your Function

First, SAM will need a template.yml file to work correctly.

From here, you can test your function and iterate as you develop locally with the command below:

sam local invoke "MyFunction" -e event.json