0.1.1 • Published 10 months ago

@webeleon/nestjs-redis v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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
0.0.10

2 years ago

0.0.11

2 years ago

0.1.0

10 months ago

0.1.1

10 months ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.4

2 years ago

0.0.0

2 years ago