Skip to content

feature request: forRootAsync missing #24

Closed
Closed
@kastov

Description

@kastov

Hi there!

Thanks for great package.

I planned to use it, but I did not found a way to inject ConfigService to provide Redis or RabbitMQ credentials.
Is it possible to do this now with forRootAsync or registerAsync option?

Like in this example:

CacheModule.registerAsync({
            imports: [ConfigModule],
            inject: [ConfigService],
            isGlobal: true,
            useFactory: async (configService: ConfigService) => {
                return {
                    stores: [
                        createKeyv(
                            {
                                url: `redis://${configService.getOrThrow<string>('REDIS_HOST')}:${configService.getOrThrow<number>('REDIS_PORT')}`,
                                database: configService.getOrThrow<number>('REDIS_DB'),
                                password: configService.get<string | undefined>('REDIS_PASSWORD'),
                            },
                        ),
                    ],
                };
            },
        })

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions