Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

387
Views
Proper way to export dynamic module

I have a NestJS application with the CoreModule which exports an collection of the core services to all other modules. In core module i have dynamic module register HttpModule. I won't to register this module twice for import and export so i do the following:

const httpModule = HttpModule.register({
    timeout: Configuration.requestTimeoutMilliseconds
});

@Module({
    imports: [httpModule],
    providers: [
        ...
    ],
    exports: [
        httpModule,
        ...
    ]
})
export class CoreModule { }

When i start my app i see in InstanceLoader logs HttpModule dependencies registered twice:

enter image description here

What the proper way to export dynamic modules in general?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can do it like this.

@Module({
  imports: [
    HttpModule.register({
      timeout: Configuration.requestTimeoutMilliseconds,
    }),
  ],
  providers: [],
  exports: [HttpModule],
})
export class CoreModule {}

Makes sense to me because when you want to implement a dynamic module, you need to return module class as a module identifier in the module field.

There are examples of declaring dynamic modules on this page in documentation https://docs.nestjs.com/fundamentals/dynamic-modules#module-configuration

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!