mahendraHegde/node-idempotency

accept inject in the rootAsync

Closed this issue · 2 comments

Allow injection in rootAsync, so we can load settings from env variables.

Example:

    NodeIdempotencyModule.forRootAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => {
        return {
          storage: {
            adapter: StorageAdapterEnum.redis,
            options: {
              url: config.get('redis.url');,
            },
          },
          cacheKeyPrefix:  config.get('cache.prefix'),
          enforceIdempotency: true,
        };
      },
    }),

Ref: https://github.com/bjerkio/nestjs-slack/blob/main/src/slack.module.ts

@euberb sounds reasonable, would you be willing to send a PR?

available in @node-idempotency/nestjs@1.0.5