I am just beginning to test and experiment different use cases with nestjs. I have implementing a global mail service for my monolith backend. Whoever, I meant change they way I am handling mailing, e.g. right know I want to use Resend.com, although I might change back to nodemailer or a different SaaS mail provider.
The project is monolith and I have created a core feature library called "mail" which handles anything related mailing as I explained at above.
I want imports module or services based on the environment variables that are provided. I did a little bit of research and I came up with this solution of using useFactory to work out the strategy and decision making of which provider has to be provided for services.