DEV Community

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

akiraah profile image

This defeats the purpose of using JavaScript to begin with. You don't need to use tools such a DI, DI was created especially for OOP languages. You can create a simple rest express app without these boilerplate code.

Thread Thread
markpieszak profile image
Mark Pieszak • Edited on

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!