DEV Community

Discussion on: Nestjs🐺⚡ | The framework of Nodejs (Part-1) | Controllers, ExceptionFilters, Providers

 
markpieszak profile image
Mark Pieszak • Edited

DI helps separate a class from its dependencies.

Take Testing for example, with DI it takes 10x less effort to swap / mock / anything you need to do.
You could test things in isolation, provide alternative testing containers (with different databases), the number of benefits highly outweighs any cons. But it always depends on the team and projects, right!

As you said for a simple Rest application, you might not even need it (or Nest), but if you're dealing with a gigantic REST or GraphQL app, or monorepo with lots of apps + micro services, it becomes really advantageous!