Node.js API server/backend based on fastify and MongoDB as a database for persisting data, GitHub Actions build and code linter, minimal tooling and native node test runner with native coverage. Can be used as a template to quickly bootstrap yor Node.js API http server project.
- automatic reloading using fastify-cli
- native ESM module (ECMAScript) with imports/exports
- load .env to environment and validate using fastify-env and dotenv
- linting and fixing using neostandard
- git pre-commit hooks using husky
- integration tests with node test runner
- coverage report using native node coverage
- continuous integration using GitHub Actions CI
- code coverage tracking using coveralls
- dependency updates notifications using dependabot
- dependency merging using GitHub Action Merge Dependabot
- authoring of release notes using release-drafter
- code linting with MegaLinter
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
git clone git@github.com:mihaur/node-fastify-template.git
cd node-fastify-template
cp .env.example .env
npm install
npm start
Use .env to store your environment dependant configuration options and secrets. This file should not be checked in to your repository, use .env.sample as example but exclude real secrets.
Linting is done using neostandard. Use npm run lint
to run linter. You can also automatically fix linter errors by running npm run lint:fix
.
Unit tests are located in src/component/__test/component.test.js. Unit tests are executed by Node test runner using npm run test:unit
.
Integration tests are located in test/**.test.js. Integration tests are executed by Node test runner using npm run test
.
Uae npm run coverage
to show coverage in the console or npm run coverage:lcov
to generate a lcov report.