I have a class and i want to instantiate the class on demand witht the Nest DI and get the class instance with all the injections, i did this in adonisjs using containers (https://docs.adonisjs.com/guides/concepts/dependency-injection#using-the-container-directly) but i cannot find something similar in NestJS.
#How to instantiate any class with Nest DI without injecting them into the provider?
1 messages · Page 1 of 1 (latest)
So, you want to create the instance on demand/when you want, but you want Nest to do the injections for you?
yes
The closest thing I could think of would be to inject the ModuleRef and the create https://docs.nestjs.com/fundamentals/module-ref#instantiating-custom-classes-dynamically
do i need to inject the class into providers before doing this?
Almost guaranteed
Hi, how do i get the metadata i set on the class with dcoarator
What metadata are you looking for in particular?
metadata set by SetMetadata
Then you'll probably use the Reflector class to get the metadata by the same key you used to set it
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).