一直在使用 Advanced NestJS 研究动态模块:如何构建完全动态的 NestJS 模块。
据我所知,大多数人使用本指南来构建同步/异步动态模块。
但是我的问题是,如果我使用 registerAsync 方法,并且我的动态模块需要导入 HttpModule,而 HttpModule 的 register-options 是由我的动态模块提供的。
如何在动态模块中导入模块,动态模块提供选项?或者是处理这个问题的错误方法?如果是这样,你会如何构建它?
这是代码。这实际上是本教程的副本。正如您在 register 方法中看到的那样,它很简单 - 我只是传入选项。registerAsync 但是,我无法弄清楚该怎么做。
任何帮助深表感谢 :)
import { Module, DynamicModule, Provider, HttpModule } from "@nestjs/common";
import { InvoicesHealth } from "./invoices/invoices.health";
import { InvoicesResolver, InvoicesService } from "./invoices";
import {
CustomerInvoicesOptions,
CustomerInvoicesAsyncOptions,
CustomerInvoicesOptionsFactory,
} from "./interfaces";
import { CUSTOMER_INVOICES_OPTIONS } from "./constants";
import { createCustomerInvoicesProviders } from "./providers/customer-invoices.providers";
@Module({
imports: [],
controllers: [],
providers: [InvoicesHealth, InvoicesResolver, InvoicesService],
exports: [InvoicesHealth],
})
export …Run Code Online (Sandbox Code Playgroud)