Optionaloptions: CqrsPluginOptions
Plugin configuration
The plugin instance
import { CqrsPlugin } from '@setu-ts/cqrs-plugin';
app.register(CqrsPlugin({
behaviors: [timingBehavior],
commandHandlers: [
{ type: CREATE_USER, handler: new CreateUserHandler() },
{ type: PLACE_ORDER, handler: createPlaceOrderCommandHandler },
],
queryHandlers: [{ type: GET_USER, handler: new GetUserHandler() }],
}));
commandHandlers, queryHandlers, and behaviors each accept an instance or a
RegistryFactory ((services: IServiceRegistry) => T). A factory is resolved at
onInit — the first phase at which the registry holds every capability — so it can
resolve any capability and build the handler or behavior with it. Instance entries
keep their register() timing.
Creates the CQRS plugin.
Registers three services:
ICommandBusunderCAPABILITIES.COMMAND_BUSIQueryBusunderCAPABILITIES.QUERY_BUSICqrsFacadeunderCAPABILITIES.CQRSSingle instance only — registering a second
CqrsPlugin()throws (duplicate capability provider, per kernel behavior).