Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@webeleon/nestjs-redis

Webeleon617MIT0.1.1TypeScript support: included

A redis client for NestJS

webeleon, npm, typescript, NestJS, redis

readme

Webeleon npm package starter

Install

npm i @webeleon/nestjs-redis

Configuration in the root module

with forRoot

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { RedisModule } from '@webeleon/nestjs-redis';
import { redisConfig } from './configurations/redis.config';

@Module({
  imports: [
    RedisModule.forRoot({
      url: 'redis://localhost:6379',
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

with forRootAsync

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { RedisModule } from '@webeleon/nestjs-redis';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { redisConfig } from './configurations/redis.config';

@Module({
  imports: [
    ConfigModule.forRoot({
      load: [redisConfig],
    }),
    RedisModule.forRootAsync({
      useFactory: async (configService) => configService.get('redis'), 
      inject: [ConfigService]
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

Usage

Import the RedisModule.forFeature() inside a feature module.

import { RedisModule } from './redis.module';

@Module({
  imports: [
    RedisModule.forFeature()
  ]
})
class SomeModule {}

Then you'll be able to inject the RedisClient inside any provider.

import { Injectable } from '@nestjs/common';
import { InjectRedisClient, RedisClient } from '@webeleon/nestjs-redis';

@Injectable()
export class SomeService {
  constructor(
    @InjectRedisClient() redisClient: RedisClient
  ) {}
}

Developers

Generate the documentation

npm run generate-doc

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.1.1 (2023-07-22)

Bug Fixes

  • deps: update nest monorepo to v10 (212c9e4)

0.1.0 (2023-07-22)

⚠ BREAKING CHANGES

  • implement forFeature method on the module

Features

  • implement forFeature method on the module (23b0c88)

0.0.11 (2022-03-11)

Features

  • add a @InjectRedisClient decorator (1c05bfa)
  • remove forFeature until i figure out how to implement it correctly (e46581d)

0.0.10 (2022-03-08)

Features

  • remove forFeature until i figure out how to implement it correctly (9de02d8)

0.0.9 (2022-03-07)

Features

0.0.8 (2022-03-06)

Bug Fixes

  • make redis option optional (e5d52ac)

0.0.7 (2022-03-06)

Bug Fixes

  • make imports and inject optional (e82a6b4)

0.0.6 (2022-03-06)

Bug Fixes

  • add imports in forRootAsync constructor (b0c41d8)

0.0.5 (2022-03-06)

Bug Fixes

  • build target in package.json (b738fb3)

0.0.4 (2022-02-25)

0.0.3 (2022-02-25)

Bug Fixes

0.0.2 (2022-02-25)

Features

  • implement forFeature method (ccc730e)

Bug Fixes

  • install reflect-metadata (c6c0f3e)

0.0.1 (2022-02-25)

Features

  • implement basic redis client module (9c4e64f)