{"id":22894262,"url":"https://github.com/clearcodehq/nodejs-microservice-boilerplate","last_synced_at":"2025-10-17T13:15:05.230Z","repository":{"id":34393102,"uuid":"145855230","full_name":"ClearcodeHQ/nodejs-microservice-boilerplate","owner":"ClearcodeHQ","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-23T21:04:09.000Z","size":443,"stargazers_count":20,"open_issues_count":14,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T13:37:09.402Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ClearcodeHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-23T13:10:10.000Z","updated_at":"2023-08-24T13:30:57.000Z","dependencies_parsed_at":"2023-02-13T03:15:32.936Z","dependency_job_id":null,"html_url":"https://github.com/ClearcodeHQ/nodejs-microservice-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Fnodejs-microservice-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Fnodejs-microservice-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Fnodejs-microservice-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClearcodeHQ%2Fnodejs-microservice-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ClearcodeHQ","download_url":"https://codeload.github.com/ClearcodeHQ/nodejs-microservice-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252941360,"owners_count":21828860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T23:17:20.972Z","updated_at":"2025-10-17T13:15:05.171Z","avatar_url":"https://github.com/ClearcodeHQ.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This is a node boilerplate for your new microservice!\n\nIt was created by the joint effort of Clearcode's PHP03 team (known also as The A Team). We've made it to make creating new microservices easier for us, as all of them share the same backbone.\n\n## Features\n\n### Metrics\n\nService metrics are exposed using [Express HTTP server](https://expressjs.com/) and [prom-client](https://github.com/siimon/prom-client) library, which serves them in a text format recognizable by the [Prometheus monitoring system](https://prometheus.io/). An example healthcheck metric is included in the `src/modules/healthcheck.js`.\n\n### Testing\n\nTesting environment is installed with dev dependencies. Our solution provides the following components:\n\n - [Mocha](https://mochajs.org/) as the base framework\n - [Chai](http://www.chaijs.com/) as the assertion library\n - [Sinon](https://sinonjs.org/) as the test doubles provider\n - [Rewire](https://github.com/jhnns/rewire) as the injector service\n - [Istanbul/NYC](https://istanbul.js.org/) as the coverage reporter\n\nA basic test for the healthcheck module is prepared in the `src/tests/healthcheck.spec.js` directory.\n\n### Docker\n\nTwo docker-compose files are prepared:\n\n - `docker-compose.yml` contains only the specification for the application itself. It is meant to be used in a local environment where external dependencies are already present, or to serve as a basis for production configuration\n - `docker-compose-local.yml` contains both the service and some external dependencies, so that the service can be used in a self-contained manner, without sharing data or resources with other microservices\n\nA Dockerfile is also present, building the image in a two-step process.\n\n### Configuration\n\nConfiguration is mainly done by utilising the environment variables. Example of these are contained in the `env.dist` file. The environment variables are utilised in the docker-compose files, as well as by the configuration file for the service, contained in the `src/config/default.js` file.\n\nService configuration converts required values from environment variables into numbers so that proper typing is ensured. It also contains a set of default values, in case some of the environment variables are missing.\n\nOne separate value is taken from `src/config/commit_sha` file. This file will contain the SHA of the commit on which the current image was built. It is supposed to be filled by Dockerfile setup and Dockerfile should receive this value from the continuous integration system. This allows us to use the value in metrics and logs, which in turn ensures that proper version of the application was deployed.\n\n### Linter\n\nConfiguration file `.eslintrc.json` is included, as well as the [eslint](https://eslint.org/) tool itself in package.json, alongside a command to run or fix the source files.\n\n### Makefile\n\nThe Makefile gives more convenient access to most frequently performed actions, such as rebuilding or starting the service, showing logs or logging into the container. It is based on the `docker-compose-local.yml` file, so all external dependencies will be run as well.\n\nYou will also be able to run tests in a docker container, as they would be in a pipeline. The results will be available in the `pipieline` directory.\n\n### Pipelines (for bitbucket)\n\nThe original project was hosted internally on bitbucket, so we have created a pipeline file for it. You may find it useful if your setup is also based there, or it may serve you as an example of CD setup.\n\n## What to do\n\nFill in .env based on .env.dist\n\nReplace:\n - `your.dockerhub.com` in docker-compose.yml, docker-compose-local.yml to your Docker repository\n - `your-service-name` in docker-compose.yml, docker-compose-local.yml, Makefile and package.json\n - `your.service.name` in docker-compose.yml, docker-compose-local.yml\n - `project-name` in .env.dist\n\nAfter that run (in the main project directory):\n\n```\nmake build\nmake start\n```\n\nThis should bring the project and external dependencies to life, unless something really unfortunate, like port conflict, happens. You can check how everything is going by checking logs:\n\n```\nmake logs\n```\n\nOr by checking if the HTTP server responds:\n\n```\ncurl 0.0.0.0:8030\n```\n\nIt should yield:\n\n```\n\u003cp\u003eIt is working!\u003c/p\u003e%\n```\n\nOr by checking the metrics:\n\n```\ncurl 0.0.0.0:8030/metrics\n```\n\nWhich should yield something like this:\n\n```\n# HELP service_is_alive Check if service is working.\n# TYPE service_is_alive counter\nservice_is_alive{hostname=\"f15d4a62c171\"} 12\n\n# HELP service_version Check service version.\n# TYPE service_version counter\nservice_version{version=\"0.0.0\"} 1\n\n# HELP service_commit_sha Check service commit sha.\n# TYPE service_commit_sha counter\nservice_commit_sha{sha=\"manual-build\"} 1\n```\n\nIf everything works as expected, you can start building your application!\n\n## Enjoy!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearcodehq%2Fnodejs-microservice-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclearcodehq%2Fnodejs-microservice-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclearcodehq%2Fnodejs-microservice-boilerplate/lists"}