Files
task-stream/libs/api/shared/application/src/lib/shared.module.ts
2026-10-03 13:40:26 +02:00

24 lines
709 B
TypeScript

import { DynamicModule, Global, Module, Type } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { AggregateRehydrator } from './aggregate-rehydrator';
/**
* Shared building blocks for every bounded context: the event store (from
* the infrastructure module plugged in by the composition root) and the
* AggregateRehydrator.
*/
@Global()
@Module({})
export class SharedModule {
static withInfrastructure(
infrastructureModule: Type | DynamicModule,
): DynamicModule {
return {
module: SharedModule,
imports: [CqrsModule, infrastructureModule],
providers: [AggregateRehydrator],
exports: [infrastructureModule, AggregateRehydrator],
};
}
}