The diagram does a good job at explaining the flow I currently have and why that is failing.
logger.module that exports a loger.service that depends on a @nestjs/mongoose LogModel.db.module that exports session.service and imports logger.module.session.service that is exported by the Db.Module and imports logger.servicemock.db.module that is exactly like the real db.module (no mocked services, the real one) except the mongoose connection is to a in-memory mongodb.session.service.spec tests file that imports mock.db.moduleHowever, I can't find any good way of providing LogModelinto log.module that doesn't need me to import @nestjs/mongooseand instantiate/wait for a new connection on every startup.
I was only able to produce 2 results:
@forwardRef(() => Logger.module.register()) or/and @forwardRef(()=> Db.module.register()) which causes heap allocation errorHow can I effectively map dependencies in an efficient way with Nestjs for this use case?
Diagram: