Router

Hierarchy

  • Router

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new Router(EventSourceableType?: EventSourceableType, InitializingMessageType?: MessageTypeCommand | Event›, routedCommands?: MessageTypeCommand›[], routedEvents?: MessageTypeEvent›[]): Router

Creates an instance of Router. Creates an instance of Router.

Parameters:

NameTypeDescription
EventSourceableType?EventSourceableTypeEventSourceable type(constructor) for routing.
InitializingMessageType?MessageTypeCommand | EventInitializing message of event sourceable.
routedCommands?MessageTypeCommand›[]Optional routed commands.
routedEvents?MessageTypeEvent›[]Optional routed events.

Returns: Router

Properties

EventSourceableType

EventSourceableType: EventSourceableType

Implementation of Router.EventSourceableType


InitializingMessageType

InitializingMessageType: MessageType‹Command | Event›

Implementation of Router.InitializingMessageType


injector

injector: Injector


routedCommands

routedCommands: MessageType‹Command›[]

Implementation of Router.routedCommands


routedEvents

routedEvents: MessageType‹Event›[]

Implementation of Router.routedEvents

Methods

handleSaveErrors

handleSaveErrors(error: Error, message: Command | Event, eventSourceableId: string | Guid): Promise‹void›

Handles errors related to persisting event sourceable.

async

throws {Error} Thrown if the error is not a instance of CommitConcurrencyError.

Parameters:

NameTypeDescription
errorErrorInstance of Error not related to domain.
messageCommand | EventInstance of Command or Event.
eventSourceableIdstring | GuidEvent sourceable identifier as string or instance of Guid

Returns: Promise‹void›


initialize

initialize(): void

Implementation of Router

Initializes Router.

throws {MissingEventSourceableError} Thrown if events sourceable is not set on router.

throws {MissingInitializingMessageError} Thrown if initializing message is not set on router and can't be resolved from event sourceable.

Returns: void


initializingMessageHandler

initializingMessageHandler(message: Command | Event): Promise‹void›

Initializing message handler.

async

throws {Error} Thrown if non-DomainError or CommitConcurrencyError is thrown on event sourceable message handler.

Parameters:

NameTypeDescription
messageCommand | EventInstance of Command or Event.

Returns: Promise‹void›


isInitializable

isInitializable(eventSourceableId: string | Guid): Promise‹boolean›

Evaluates whether identifier already exists.

async

Parameters:

NameTypeDescription
eventSourceableIdstring | GuidIdentifier as string or Guid instance.

Returns: Promise‹boolean›

Returns true if identifier is initializable(does not exists), else false.


messageHandler

messageHandler(message: Command | Event): Promise‹void›

Default message handler.

async

throws {Error} Will throw an error if error is thrown on event sourceable message handler and is not a DomainError or CommitConcurrencyError error type.

Parameters:

NameTypeDescription
messageCommand | EventInstance of Command or Event.

Returns: Promise‹void›


setupCommandHandler

setupCommandHandler(CommandType: MessageTypeCommand›): void

Implementation of Router

Registers default message handler for routed command on command bus.

Parameters:

NameTypeDescription
CommandTypeMessageTypeCommandCommand type constructor.

Returns: void


setupEventHandler

setupEventHandler(EventType: MessageTypeEvent›): void

Implementation of Router

Registers default message handler for routed event on event bus.

Parameters:

NameTypeDescription
EventTypeMessageTypeEventEvent type constructor.

Returns: void