Skip to content
Advertisement

Tag: dependency-injection

In the next major version, Nest will not allow classes annotated with @Injectable(), @Catch(), and @Controller() decorators

I’m writing in Nest.js framework for 3 years and i got the message in by backend-application: I researched nest.js github and stuck what is the problem and why it says about some deprecation of useable decorators. Does anyone know how to solve this problem or what will be in the next major version of Nest.js framework Thanks in advance! Answer

Is there a way to use static method with dependency injection in NestJS?

An example is better than a long explanation: How can I replace BakeryService.myStaticMethodToGetPrice() to use dependency injection, so I can test things easily for example? Answer Static methods cannot use dependency injection. This is because the idea of dependency injection (at least to Nest) is to inject instances of the dependencies so that they can be leveraged later. The code

Advertisement