View on GitHub

api-server-template

A template project for Node.js HTTP API

API Server Template

A template project for Node.js HTTP API

Key Features

  1. Uses latest LTS node.js (v8.9.x)
  2. Builds a lightweight (Node Alpine) Docker container following best practices.
  3. Uses node-config for easy config management.
  4. A functional Jenkinsfile for CI/CD, setup to be configured with Nomad/Kubernetes container orchestration.
  5. Super fast pino.js logger
  6. Follow these simple steps to use this template.

Description

Web Framework

Fastify

Testing

Philosophy

For example my-module.js will be colocated with my-module.spec.js file.

ESLint

Mocha

Chai

Sinon

Supertest

nyc Code Coverage

CI/CD

CloudFormation to create cloud resources

npm-run-all

Rakefile

Why not just use npm scripts or Grunt or Gulp?

We want to ensure that we are able to run scripts after devDependencies have been pruned for the project. One way is to manipulate how and when devDependencies are installed or keep the logic simple. All the CI/CD orchestration is baked into the Rakefile.

Why not bake all CI CD logic in the Jenkinsfile?

From my experience baking deployment/build logic in Jenkinsfile/Groovy is extremely painful. Rakefile is a modern version of a task system much like Make. It is an extremely flexible and testable task system. Having a file like this helps the repository portable with any kind of CI/CD tool. Jenkins has been configured in this case.

NOTE: The CI/CD runtime must include node.js , Ruby and Rake. This is only required at build time

Jenkins with Scripted Pipelines

When a commit happens on master branch

When a commit happens on a hotfix branch

Deploying to an environment using Docker Artifact

Container Scheduler / Orchestrator

It is extremely common these days to to use a Container orchestration and scheduling system like :

Because a system like this is considered infrastructure related:

Both these files are consumed in the Jenkinsfile.