import { Module } from '@nestjs/common'; import { MeshModule } from '../mesh/mesh.module.js'; import { MeshService } from '../mesh/mesh.service.js'; import { RssModule } from '../rss/rss.module.js'; import { RssService } from '../rss/rss.service.js'; import { CommandService } from './command.service.js'; @Module({ imports: [MeshModule, RssModule], // one-way only — the MeshService reverse edge is wired in the factory below, not via DI providers: [ { provide: CommandService, useFactory: (mesh: MeshService, rss: RssService) => { const commands = new CommandService(mesh, rss); // break the cycle: MeshService can't inject us (its own factory would deadlock on this edge), so attach ourselves once we exist — mesh is guaranteed created here because it's our injected dependency mesh.attachCommands(commands); return commands; }, inject: [MeshService, RssService], }, ], exports: [CommandService], }) export class CommandModule {}