A template project for Node.js HTTP API
- Uses latest LTS node.js (v8.9.x)
- Builds a lightweight (Node Alpine) Docker container following best practices.
- Uses node-config for easy config management.
- A functional Jenkinsfile for CI/CD, setup to be configured with Nomad/Kubernetes container orchestration.
- Super fast pino.js logger
- Follow these simple steps to use this template.
- A fast lightweight Node.js framework for building http apis
- Out of box schema support
- Strong plugin architecture
- All unit and integration tests are colocated with the system under test.
For example my-module.js
will be colocated with my-module.spec.js
file.
- All Http/Functional tests are located in the e2e directory
- Along with popular airbnb config, helps the code lint free!
- De-facto testing framework for node.js
- All configuration has been stored in the mocha directory.
- De-facto assertion framework for node.js
- De-facto mocking framework for node.js
- A feature complete Http API and connect based applications
- De-facto javascript code coverage tool.
-
All cloudformation stacks are located at infra directory
- prod-cf.yml for PRODUCTION
- stage-cf.yml for STAGE
- Simple node module to run npm script in sequence or parallel
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.
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
- Run ci
- Build Docker container
- Publish Docker container
- Publish Nomad Job to default environment (eg: STAGE)
- Run ci
- Build Docker container
- Publish Docker container
- Publish Nomad Job to PRODUCTION environment
-
Go to Jenkins
-
Navigate to the Job
-
Build with Parmeters
-
Fill out the form
- Provide the ARTIFACT_NAME e.g.
api-server-template:latest
- Pick an environment to deploy
- Click Build
- Provide the ARTIFACT_NAME e.g.
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.