Cqrs
CQRS module
Installation#
Options#
| key | Description | Type | Default |
|---|---|---|---|
commandsBusId | Commands Bus id name | string | commandsBus |
eventsBusId | Events Bus id name | string | eventsBus |
queryBusId | QueryBus id name | string | queryBus |
in config/modules/all.ts
Commands#
first we crate command and command handler.
The command handler will publish events on the commands bus.
we execute commands using commandBus.
now we create command handler that execute the command
Events#
events handlers listen to events bus and react to events
Queries#
queries used to query handler asynchronously
now we can query for data using the queryBus
Sagas#
sagas used to listen to multi events and fire new commands
Bus#
you can use cqrs with @appolo/bus and class-transformer
you will need to load the bus module in modules config
now call the commands events and queries will be published to rabbitMQ
it is possible to define custom bus options