Answer the question
In order to leave comments, you need to log in
How to make NestJS provider global?
At the root of app.module.ts I specified:
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
// some-other-module
@Module({providers: [ConfigService]})
// MyModule.ts
@Global()
@Module({providers: [MyService], exports: [MyService]})
export class MyModule{}
MyService
in another module, I can not import it MyModule
, but MyService
I still need to import it into providers. Is it possible to make it so that MyService
it was not possible to enter separately? Exactly the same asConfigService
Answer the question
In order to leave comments, you need to log in
We use Global, services work fine with each other
. Everything frays, since the decorator is removed and the connection between them is broken
Restoring the connection by adding SomeModule to SecondModule imports
It's not entirely clear what exactly you don't like.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question