import { DynamicModule, Module, Type } from '@nestjs/common'; import { CqrsModule } from '@nestjs/cqrs'; import { TRACKER_FACTORIES } from '@task-stream/api/tracker/domain'; import { ChangesService } from './changes.service'; import { COMMAND_HANDLERS } from './commands/command-handlers'; import { WriteAccess } from './commands/write-access'; import { CommentsService } from './comments.service'; import { EVENT_HANDLERS, ReadModelNotifier, } from './event-handlers/event-handlers'; import { IssuesService } from './issues.service'; import { ProjectsService } from './projects.service'; import { QUERY_HANDLERS } from './queries/query-handlers'; import { ReadAccess } from './queries/read-access'; import { ReleasesService } from './releases.service'; import { WorkflowsService } from './workflows.service'; const SERVICES = [ ProjectsService, IssuesService, CommentsService, ReleasesService, ChangesService, WorkflowsService, ]; /** * Use cases of the tracker context. The infrastructure module implementing * its ports (lookups, read model, change feed, user directory) is plugged in * by the composition root; the event store comes from the SharedModule. */ @Module({ imports: [CqrsModule], providers: [ ...SERVICES, ...TRACKER_FACTORIES, WriteAccess, ReadAccess, ReadModelNotifier, ...COMMAND_HANDLERS, ...QUERY_HANDLERS, ...EVENT_HANDLERS, ], exports: SERVICES, }) export class TrackerApplicationModule { static withInfrastructure( infrastructureModule: Type | DynamicModule, ): DynamicModule { return { module: TrackerApplicationModule, imports: [infrastructureModule], }; } }