DEV Community

Discussion on: Providing Providers to Dynamic NestJS Modules

Collapse
 
jmcdo29 profile image
Jay McDoniel

Ah, you're right. I forgot that the default of createConfigurableDynamicModule expects the module's name to be passed as the first parameter. I'll get that fixed

Collapse
 
koakh profile image
Mário Monteiro • Edited

for other noobs like me, we need to add AuthModule ex AuthModule.forRootAsync(AuthModule

@Module({
  imports: [
    AuthModule.forRootAsync(AuthModule, {
      imports: [ConfigModule, UserModule],
      inject: [ConfigService, UserService],
      useFactory: (config: ConfigService, userService: UserService) => {
        return {
          secret: config.get('AUTH_SECRET_VALUE'),
          userService,
        };
      },
    }),
  ],
})
Enter fullscreen mode Exit fullscreen mode