Node.js API server based on fastify + MongoDB project template

December 17, 2024 ยท View on GitHub

neostandard javascript style Conventional Commits GitHub Actions CI Coverage Status MegaLinter

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.

All features

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Installing

  • git clone git@github.com:mihaur/node-fastify-template.git
  • cd node-fastify-template
  • cp .env.example .env
  • npm install
  • npm start

Configuring

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 and code fixing

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

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

Integration tests are located in test/**.test.js. Integration tests are executed by Node test runner using npm run test.

Coverage reports

Uae npm run coverage to show coverage in the console or npm run coverage:lcov to generate a lcov report.