/nestjs-cqrs

Introduction with CQRS pattern

Primary LanguageTypeScript

Introduction to NestJs + CQRS + Kafka.

Description

This project utilize NestJs CQRS and Kafka modules, using message and event based patterns. No Authentication needed, just plain API

Application is divided into two apps this one "nestjs-cqrs" and second "nestjs-cqrs-kafka" https://github.com/Nicram97/nestjs-cqrs-kafka-consumer

HOW TO

Install

run "npm install"

Start kafka + zookeeper + kafka UI

run "docker-compose up"

Run the app

run "npm run start" or "nest start" or use launch.json if You work on vs-code.

Check KafkaUI

When docker-compose is running in default state go to: "http://localhost:8080/ui"

Run hello world CQRS

Send http request GET to "http://localhost:3001/hello-world/Test" it will run simple CQRS command with helloWorld example

Test message pattern communication with kafka

Send GET request to "http://localhost:3001/kafka-message" this request should send message to two different topics and get response from them and return them in array

Test event-based pattern communication with kafka

Send GET request to "http://localhost:3001/kafka-event" this request should emit event to kafka, which should be consumed by consumer app and then consumer should reply to .response event and then main app would consume it and process.

Perform CQRS + Kafka request

Send POST request to "http://localhost:3001/${NAME}" this request should begin full procedure to launch multiple events and commands using CQRS then one of the events is send to Kafka, which will be caught by consumer service which will also response to Kafka with event, then producer will catch response event and proceed further with CQRS, sagas etc.