# @webeleon/nestjs-redis

> A redis client for NestJS

Latest version **0.1.1** (published 2023-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webeleon/nestjs-redis
pnpm add @webeleon/nestjs-redis
yarn add @webeleon/nestjs-redis
bun add @webeleon/nestjs-redis
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-07-22 |
| First published | 2022-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 167 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Julien Prugne |
| Maintainers | julien_webeleon, bassochette |
| Keywords | webeleon, npm, typescript, NestJS, redis |

## Links

- npm: https://www.npmjs.com/package/@webeleon/nestjs-redis
- Repository: https://github.com/Webeleon/nestjs-redis
- Homepage: https://github.com/Webeleon/nestjs-redis#readme
- Issues: https://github.com/Webeleon/nestjs-redis/issues
- npm.io page: https://npm.io/package/@webeleon/nestjs-redis

## Dependencies (5)

- [rxjs](https://npm.io/package/rxjs.md) 7.8.1
- [redis](https://npm.io/package/redis.md) 4.6.7
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) 10.1.0
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) 10.1.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) 0.1.13

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2023-07-22
- 0.1.0 — 2023-07-22
- 0.0.11 — 2022-03-11
- 0.0.10 — 2022-03-08
- 0.0.9 — 2022-03-07
- 0.0.8 — 2022-03-06
- 0.0.7 — 2022-03-06
- 0.0.6 — 2022-03-06
- 0.0.5 — 2022-03-06
- 0.0.4 — 2022-02-25
- 0.0.0 — 2022-02-25

## README

# Webeleon npm package starter

## Install

```bash
npm i @webeleon/nestjs-redis
```

## Configuration in the root module
### with forRoot

```ts
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

```ts
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.
```ts
import { RedisModule } from './redis.module';

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

Then you'll be able to inject the RedisClient inside any provider.
```ts
import { Injectable } from '@nestjs/common';
import { InjectRedisClient, RedisClient } from '@webeleon/nestjs-redis';

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

## Developers
### Generate the documentation

```bash
npm run generate-doc
```

---
_Source: https://npm.io/package/@webeleon/nestjs-redis · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
