Setu-TS
    Preparing search index...

    Function CqrsPlugin

    • Creates the CQRS plugin.

      Registers three services:

      • ICommandBus under CAPABILITIES.COMMAND_BUS
      • IQueryBus under CAPABILITIES.QUERY_BUS
      • ICqrsFacade under CAPABILITIES.CQRS

      Single instance only — registering a second CqrsPlugin() throws (duplicate capability provider, per kernel behavior).

      Parameters

      Returns IPlugin

      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.

      0.1.0