A Node.js CQRS/ES Swagger API Microservice Boilerplate
This is an application boilerplate that demonstrates how to use Nest.js and Event Store to create a RESTful Users API microservice.
Please note that commands have been implemented and they do write into the Event Store, however, queries for denormalized views have some boilerplate but it is up to you to implement them using your favorite database technology of choice. (use MongoDB in my position, suggest use NoSql or PostgreSql)
In case you don't feel like downloading dependencies locally, I've added support for Docker so follow those instructions in "Running the app" and you'll have everything up and running in less than 2 minutes.
The system has 6 main folder (can run as a stand-alone) as located in ./src
server
- main web api build with NestJSclient
- web proxy for navigate request and security networkclient/ui
- web ui for main applicationcore
- web api build with Python Flask for transcript audio file to textrelease
- release plan and steps build systemservices
- stack for deploy application with Event Store, GCloud, Jenkins, Nginx, Kafka, Redis
Name | Version |
---|---|
EventStore | latest |
Node.js | Dubnium |
TypeScript | 3 |
Docker Compose | 3 |
With Docker
- Install Docker (from the Docker website)
- Fork and clone the ViSpeech repo (see Contributing page)
- From the src folder run:
docker-compose up
- Open a browser and navigate to http://localhost to see the application running
- To shutdown the application run:
docker-compose down
Without Docker (for development/debugging)
-
Fork and clone the ReactiveTraderCloud repo (see Contributing page)
-
Install dependencies & add them to your path:
-
Enable Kafka
tar -xzf kafka_2.12-2.5.0.tgz cd kafka_2.12-2.5.0 bin/zookeeper-server-start.sh config/zookeeper.properties bin/kafka-server-start.sh config/server.properties
-
Populate Event Store:
EventStore.ClusterNode.exe --db ./db --log ./logs
-
Start the ViSpeech server:
cd src/server npm install npm run start
-
(Optional) Start Node services by running
npm run start:dev
from their respective folders, e.g.:cd src/server/node/priceHistory npm install npm run start:dev
-
Start the client against the local server components:
cd src/client npm install npm run start:dev cd src/client/ui npm install npm run start
We practice continuous integration and deployment. Every merge to master causes a build and deployment to our development environment to occur as follows:
# development
$ yarn start
# watch mode
$ yarn start:dev
# production mode
$ yarn start:prod
# analyze production mode
$ yarn start:analyze
# using with Docker
$ ./scripts/up.sh # to start
$ ./scripts/down.sh # to stop
Medium Article (Part 1): https://medium.com/@qasimsoomro/building-microservices-using-node-js-with-ddd-cqrs-and-event-sourcing-part-1-of-2-52e0dc3d81df
Medium Article (Part 2): https://medium.com/@qasimsoomro/building-microservices-using-node-js-with-ddd-cqrs-and-event-sourcing-part-2-of-2-9a5f6708e0f
Swagger Explorer URL: http://localhost:7070/api
Event Store URL: http://localhost:2113
# unit tests
$ yarn test
# e2e tests
$ yarn test:e2e
# test coverage
$ yarn test:cov
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.
Client libraries targetting some end-of-life versions of Node.js are available, and
can be installed via npm dist-tags.
The dist-tags follow the naming convention legacy-(version)
.
Legacy Node.js versions are supported as a best effort:
- Legacy versions will not be tested in continuous integration.
- Some security patches may not be able to be backported.
- Dependencies will not be kept up-to-date, and features will not be backported.
This library follows Semantic Versioning.
This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.