Backend Node (be-node-express)

Purpose of this quickstarter (use this when you want to …​)

This is a node (v10) quickstarter with express using Typescript. If you are doing non-blocking operation and does not have heavy algorithm/Job which consumes lots of CPU power, this could be an ideal fit. It contains a basic setup for Docker, Jenkins, SonarQube and OpenShift.

What files / architecture is generated?

The package json is generated by simply using npm init -y, while the tsconfig is generated using tsc --init --skipLibCheck --outDir "./dist". The dependencies mentioned below are added to plain package.json file. On top of that, test, build and start script commands are customized to get your node/express application up and running with typescript.

├── Jenkinsfile - Contains Jenkins build configuration
├── docker - Contains Dockerfile for the build
│   └── Dockerfile
├── package-lock.json - Commit this file as well when you update your dependencies
├── package.json - This file contains all the npm dependencies and build commands for the project.
├── metadata.yml - Component metadata
├── release-manager.yml - Configuration file for the Release Manager
├──  - SonarQube Configuration
├── src
│   ├── sum.ts -   Sample function
│   ├── index.ts -  Entrypoint, This runs first
├── __test__
│   ├── sum.spec.ts -  Sample test
├── tsconfig.json - TypeScript Configuration file
└── tslint.json - TypeScript Linter Configuration


On top of the mentioned frameworks above, we use libraries:

Node version

When you push your code, your runtime and test code will be compiled using node v10. After deployment the compiled code also runs in node v10. If you developed your code and tests using a different node version locally, this might cause some problems.

This is why we made the tsconfig.json file to be compatible with node v10. So bear in mind that any changes to compiler options might result in compilation and runtime errors. Here are our related changes to tsconfig.json file below:

  "compilerOptions": {
    "lib": ["es2018"],
    "module": "commonjs",
    "target": "es2018"

Usage - how do you start after you provisioned this quickstarter

  1. npm install forms the project root to install all the dependencies

  2. npm run build transpiles the typescript code to /dist folder

  3. npm run start starts the node server

  4. npm run test runs tests located under /dist folder, prints the jest output under /build folder and reports test coverage. The report located under /coverage_output folder is then picked by Sonarqube.

How this quickstarter is built through jenkins

The build pipeline is defined in the Jenkinsfile in the project root. The mains stages of the pipeline are,

  1. Build : npm run build command is executed to build the application and then the build is copied to the docker/dist folder.

  2. Unit Testing : npm run test command is executed for running unit tests and to generate coverage report. The results can be seen form the Jenkins console output.

Builder agent used

This quickstarter uses Nodejs10-Angular builder agent Jenkins builder agent.

Known limitations