Giter VIP home page Giter VIP logo

0xb4lamx / nestjs-boilerplate-microservice Goto Github PK

View Code? Open in Web Editor NEW
445.0 8.0 54.0 2.02 MB

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

License: MIT License

TypeScript 80.61% Shell 13.29% Dockerfile 1.68% JavaScript 3.69% Makefile 0.73%
microservice nestjs boilerplate eventstore cqrs nodejs graphql eventsourcing ddd saga

nestjs-boilerplate-microservice's Introduction

Description

Microservice boilerplate based on NestJS v10, built with TypeScript. Commitizen friendly

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. This project cover both, running on a containerized environment using Docker, or on your local machine.

Guidelines

Setup

Docker Environment

This section will cover the steps to follow for a containerized version of this project.

Prerequisites

Installation

(cd scripts/ && sh build.sh)

The build script Will:

  • Create private network for containers.
  • Configure and deploy MYSQL container.
  • Configure and deploy Adminer container.
  • Configure and deploy EventStore container.
  • Configure and deploy nestjs-boilerplate container.
  • Connect containers to private network.
  • Enables hot-reloading by mounting working directories inside nestjs-boilerplate container.
  • Create and mount data directory to mysql container for persistence under $HOME/mysql-data-dir.
  • Create and mount data directory to EventStore container for persistence under $HOME/eventstore-data-dir.

Usage

Access

  • EventStore:
    • credentials:

      User Password
      admin changeit
  • Adminer
    • Form

      Server User Password Database
      sql-db root root demo-db
  • Microservice Docker Container
        sudo docker exec -it devtest bash

Clean up

Soft clean up

(cd scripts/ && sudo sh cleanup.sh)

The cleanup script soft Will:

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

Hard clean up

#both commands are equivalent
#option1 
(cd scripts/ && sudo sh cleanup.sh -h)
#option2
(cd scripts/ && sudo sh cleanup.sh --hard)

The cleanup script hard Will:

  • 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.

local Environment

This section will cover the steps to follow for a local version of this project.

Prerequisites

PS: in order to start receiving events from the EventStore, you should enable projections. (disabled by default)

Installation

$ npm install

Database setup

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# debug mode
$ npm run start:debug

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Built With

  • Docker - Containerization technology
  • npm - Dependency Management
  • Nest

Future Goals

Add tests;

Contributing

You are welcome to contribute to this project, just open a PR.

License

MIT licensed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.