Microservice boilerplate based on NestJS v7, built with TypeScript.
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.
This section will cover the steps to follow for a containerized version of this project.
- A Docker engine running on your local machine. Reffer to official documentation for intructions.
- Post-installation steps for Linux. Reffer to official documentation for intructions.
(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.
- To access the App home page navigate to http://localhost:3000 [DEFAULT PORT].
- To access the EventStore Admin UI navigate to http://localhost:2113 [DEFAULT PORT].
- To access the Adminer UI navigate to http://localhost:8080 [DEFAULT PORT].
- To change default setting, edit script/dev/evVAr.sh
- EventStore:
-
credentials:
User Password admin changeit
-
- Adminer
-
Form
Server User Password Database sql-db root root b2h-db
-
- Microservice Docker Container
sudo docker exec -it devtest bash
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.
This section will cover the steps to follow for a local version of this project.
- A running EventStore. Reffer to official documentation for intructions.
- A running Mysql Server. Reffer to official documentation for intructions.
- A running Node Server. Reffer to official documentation for intructions.
- npm
PS: in order to start receiving events from the EventStore, you should enable projections. (disabled by default)
$ npm install
- using TypeORM CLI. Reffer to migration documentation for intructions.
# development
$ npm run start
# watch mode
$ npm run start:dev
# debug mode
$ npm run start:debug
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Add tests;
You are welcome to contribute to this project, just open a PR.