Cqrs
CQRS module
#
Installation#
Optionskey | 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
#
Commandsfirst 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
#
Eventsevents handlers listen to events bus and react to events
#
Queriesqueries used to query handler asynchronously
now we can query for data using the queryBus
#
Sagassagas used to listen to multi events and fire new commands
#
Busyou 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