Skip to content

Using typed config in module setup #79

Answered by Nikaple
Aadmaa asked this question in Q&A
Discussion options

You must be logged in to vote

Just inject the config model, as TypedConfigModule is registered as global module by default:

@Module({
  imports: [
    TypedConfigModule.forRoot({
      schema: RootConfig,
      load: dotenvLoader(),
      normalize: (config) => configuration((config))
    }),
    RedisModule.forRootAsync({
      useFactory: (config: RedisConfig) => ({
        config: {
          host: config.endpoint,
          password: config.password,
          port: config.port,
        },
        commonOptions: {
          retryStrategy: times => Math.max(times * 100, 3000)
        }
      }),
      // inject any config model
      inject: [RedisConfig]
    })
  ],
  controllers: [AppController],
  providers: [
    

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nullbuddy1243
Comment options

Answer selected by Aadmaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants