I think it's essential for any NestJS libraries to be able to support dynamic configurations, as many of us want to inject loadable configurations based on certain business logic or simple because we want to load them from another service, so there's a conventional approach using Dependency Injection so that by exposing a static method called: registerAsync. So for instance, we can follow this guide, because doing it manually can be a bit overwhelming.
If you want I can organice a PR with this functionality, the register will always be supported for the dynamic module, but also it will support theregisterAsync method.
Proposal:
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PrismaClient } from '@prisma/client';
import { PrismaModule } from '@sabinthedev/nestjs-prisma';
import { ConfigService } from './config/config.service.ts';
@Module({
imports: [
PrismaModule.registerAsync({
useFactory: (config: ConfigService) => ({
client: PrismaClient,
name: config.get('database.name'),
multitenancy: config.get('database.allowMultitenancy'),
datasource: config.get('database.url'),
})
})
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule { }
I think it's essential for any NestJS libraries to be able to support dynamic configurations, as many of us want to inject loadable configurations based on certain business logic or simple because we want to load them from another service, so there's a conventional approach using Dependency Injection so that by exposing a static method called:
registerAsync
. So for instance, we can follow this guide, because doing it manually can be a bit overwhelming.If you want I can organice a PR with this functionality, the
register
will always be supported for the dynamic module, but also it will support theregisterAsync
method.Proposal: