I have an object describing a nestjs module
const objectAppModule = {
imports: [],
exports: [],
controllers: [
MyController
],
providers: [
provide: 'ControllerDependency',
useValue: MyDependency
]
}
I want to pass this to the NestFactory to create my Nest application.
The NestJs way of doing this is to create a class MyAppModule and to add a decorator.
@Module(objectAppModule)
export class ClassAppModule {}
Then pass it to the NestFactory
const app = await NestFactory.create(ClassAppModule);
I want to achieve the same but without using the @Module decorator. The decorator adds some functionality to the class which is missing in my object but I can't quite figure out what is required.
How can I replicate this functionality to do something like this instead?
const app = await NestFactory.create(objectAppModule);
To flesh out @Jay McDoniel's comment, the following worked;
export class DummyClass { }
const objectAppModule: DynamicModule = {
module: DummyClass
imports: [],
exports: [],
controllers: [
MyController
],
providers: [
provide: 'ControllerDependency',
useValue: MyDependency
]
}
const app = await NestFactory.create(objectAppModule);