Nestjs Boilerplate Microservice

screenshot of Nestjs Boilerplate Microservice
nestjs

Nestjs Boilerplate Microservice

Nestjs Microservice boilerplate: apply DDD, CQRS, and Event Sourcing within an event driven architecture

Product Analysis

Overview:

This is a microservice boilerplate based on NestJS v10, built with TypeScript. It is designed to be commitizen friendly and provides a starting point for developing and testing microservices. The project can be run on a containerized environment using Docker or on a local machine.

Features:

  • NestJS v10: Based on the latest version of NestJS, providing a robust framework for building microservices.
  • TypeScript: Built with TypeScript, making it easier to write and maintain code.
  • Commitizen friendly: Designed to be compatible with commitizen, facilitating standardized commit messages.

Installation:

Setup Docker Environment:

Prerequisites:

  • Docker engine running on your local machine.
  • Post-installation steps for Linux.

Installation: The build script will perform the following steps:

  1. Create a private network for containers.
  2. Configure and deploy MYSQL container.
  3. Configure and deploy Adminer container.
  4. Configure and deploy EventStore container.
  5. Connect containers to private network.
  6. Enable hot-reloading by mounting working directories inside nestjs-boilerplate container.
  7. Create and mount data directory to mysql container for persistence.
  8. Create and mount data directory to EventStore container for persistence.

Usage:

  • Access the App home page by navigating to http://localhost:3000.
  • Access the EventStore Admin UI by navigating to http://localhost:2113.
  • Access the Adminer UI by navigating to http://localhost:8080.
  • To change default settings, edit the script/dev/evVAr.sh file.

Access EventStore credentials: |User|Password| |--|--| |admin|changeit|

Adminer Form Credentials: |Server|User|Password|Database| |--|--|--|--| |sql-db|root|root|demo-db|

Microservice Docker Container Clean Up: The cleanup script provides two options: soft clean up and hard clean up.

Soft clean up:

  • Remove private network.
  • Stop and remove MYSQL container.
  • Stop and remove Adminer container.
  • Stop and remove EventStore container.

Hard clean up:

  • Remove private network.
  • Stop and remove MYSQL container.
  • Stop and remove Adminer container.
  • Stop and remove EventStore container.
  • Delete Mysql data directory.
  • Delete EventStore data directory.

Setup Local Environment:

Prerequisites:

  • Running EventStore.
  • Running Mysql Server.
  • Running Node Server.
  • npm

Installation:

  • Database setup using TypeORM CLI. Refer to the migration documentation for instructions.

Summary:

The microservice boilerplate is built with NestJS v10 and TypeScript, providing a solid foundation for developing and testing microservices. It offers features like commitizen compatibility and can be run on a containerized environment using Docker or on a local machine. The installation process includes setup for both environments, and cleanup scripts are provided for easy removal of containers and data directories. Overall, this boilerplate aims to streamline the development process and provide an efficient starting point for building microservices.

nestjs
Nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

graphql
Graphql

A website that uses GraphQL as a query language to manage data fetching and state management. This includes features such as a strongly typed schema, client-side caching, and declarative data fetching to streamline data management and optimize website performance.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.