DEV Community

Discussion on: Build a NestJS Module for Knex.js (or other resource-based libraries) in 5 Minutes

Collapse
 
johnbiundo profile image
John Biundo

@fwoellfel, thanks! Glad it has been helpful!

Not dumb at all! I should probably discuss the use of @Global() in the article, so thanks for bringing it up. The main reason I use it is, to be honest, in a "utility" type module I find it convenient to register it once (usually in the root module), and then have it globally available. However you bring up an excellent point, and @Global() definitely has some side effects (such as breaking module encapsulation) and is usually to be avoided. I want to give this some more thought, and I have an idea or two on how to handle your Module A/Module B question, but need to test a few things out. I'll report back!

And your second question is good as well! To be honest, I hadn't quite sussed out that pattern of register vs. forRoot, but now that you mention it, I'll have to go back and look more closely.

Thanks so much for the thoughtful feedback. It really helps to have sharp eyes from people who have worked on dynamic modules. I hope to continue to improve these articles as a useful resource!