Skip to content

Commit

Permalink
feat: add for root method to register cqrs globally
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Aug 3, 2023
1 parent 19d8ace commit 0f8dd39
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cqrs.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module, OnApplicationBootstrap } from '@nestjs/common';
import { DynamicModule, Module, OnApplicationBootstrap } from '@nestjs/common';
import { CommandBus } from './command-bus';
import { EventBus } from './event-bus';
import { EventPublisher } from './event-publisher';
Expand Down Expand Up @@ -27,6 +27,17 @@ import { UnhandledExceptionBus } from './unhandled-exception-bus';
export class CqrsModule<EventBase extends IEvent = IEvent>
implements OnApplicationBootstrap
{
/**
* Registers the CQRS Module globally.
* @returns DynamicModule
*/
static forRoot(): DynamicModule {
return {
module: CqrsModule,
global: true,
};
}

constructor(
private readonly explorerService: ExplorerService<EventBase>,
private readonly eventBus: EventBus<EventBase>,
Expand Down

0 comments on commit 0f8dd39

Please sign in to comment.