Hello! I'm developing a Node.JS/Express API with Typescript, and there is a certain Service (or use case), which is used in a number of routes, that has many dependencies (I.E: database Repositories and other Services), so everytime I have to instance Service X on the controller, I need to instance a bunch of repositories and other services (which themselves have their dependencies, some of which are in common with ServiceX) , and finally pass them as dependencies on the constructor of ServiceX.
I'm already using the Dependency Inversion pattern, so that it is the client code that needs to instance those dependencies and pass it to them, but I'd like to define a "factory" somehow (not sure if literally using the Factory pattern, or just as a way of saying), and then call this "factory" in all the places I need this Service.
Thanks in advance for any help! I can provide a code example if this sounds confusing, just didn't want to paste a giant block of code for no reason.