Concrete command bus implementing ICommandBus.
-
clear(): void
Clears all registered command handlers.
-
execute<TResult = unknown>(command: CqrsCommand): Promise<TResult>
Executes a command.
-
handlerCount(): number
The number of registered command handlers.
-
register<TCommand extends CqrsCommand, TResult>(): voidtype: string,handler: ICommandHandler<TCommand, TResult>
Registers a command handler.
-
setBehaviors(behaviors: readonly IPipelineBehavior[]): void
Replaces the behavior list.
Thrown by CommandBus.execute and QueryBus.execute
when no handler is registered for the request's type.
-
requestType: string
The request type that had no handler.
Concrete query bus implementing IQueryBus.
-
clear(): void
Clears all registered query handlers.
-
execute<TResult = unknown>(query: CqrsQuery): Promise<TResult>
Executes a query.
-
handlerCount(): number
The number of registered query handlers.
-
register<TQuery extends CqrsQuery, TResult>(): voidtype: string,handler: IQueryHandler<TQuery, TResult>
Registers a query handler.
-
setBehaviors(behaviors: readonly IPipelineBehavior[]): void
Replaces the behavior list.
Creates the CQRS plugin.
One command handler and the command type the bus routes to it.
-
handler: ICommandHandler | RegistryFactory<ICommandHandler>
The handler to register for that type, or a factory that builds one from the service registry.
-
type: string
Command type name, matching
command.type.
A command: a request that mutates state and returns a result.
Options for CqrsPlugin.
-
behaviors: readonly (IPipelineBehavior | RegistryFactory<IPipelineBehavior>)[]
Pipeline behaviors applied to every command and query execution.
-
commandHandlers: readonly CommandHandlerRegistration[]
Command handlers registered on the command bus at
register()time. -
queryHandlers: readonly QueryHandlerRegistration[]
Query handlers registered on the query bus at
register()time.
A query: a request that returns data without side effects.
A CQRS request identified by a string type and carrying typed data.
-
data: TData
The request payload.
-
type: string
Request type name (e.g.
"CreateUser"). Used for routing.
Registers and executes commands.
-
execute<TResult = unknown>(command: CqrsCommand): Promise<TResult>
Executes a command.
-
register<TCommand extends CqrsCommand, TResult>(): voidtype: string,handler: ICommandHandler<TCommand, TResult>
Registers a handler for a command type.
Handles one command type.
-
handle(command: TCommand): TResult | Promise<TResult>
Executes the command.
Facade combining command and query buses.
-
commandBus: ICommandBus
The command bus.
-
queryBus: IQueryBus
The query bus.
Wraps a handler with cross-cutting logic (logging, timing, validation, etc.).
-
handle(): TResult | Promise<TResult>request: TRequest,next: () => Promise<TResult>
Wraps the next handler in the pipeline.
Registers and executes queries.
-
execute<TResult = unknown>(query: CqrsQuery): Promise<TResult>
Executes a query.
-
register<TQuery extends CqrsQuery, TResult>(): voidtype: string,handler: IQueryHandler<TQuery, TResult>
Registers a handler for a query type.
Handles one query type.
-
handle(query: TQuery): TResult | Promise<TResult>
Executes the query.
One query handler and the query type the bus routes to it.
-
handler: IQueryHandler | RegistryFactory<IQueryHandler>
The handler to register for that type, or a factory that builds one from the service registry.
-
type: string
Query type name, matching
query.type.
Usage
import * as CQRS_plugin__command_bus__query_bus__and_pipeline_behaviors__ from "cqrs-plugin/src/index.ts";