Registry / database / nestjs-power-redis

nestjs-power-redis

JSON →
library1.0.18jsnpmunverified

NestJS integration for power-redis, providing a secure, scalable, and production-ready Redis client wrapper with multi-connection support, TLS, and high-performance helpers. Current stable version is 1.0.18, actively maintained. It supports defining multiple named Redis connections via environment variables, auto-loading TLS certificates, and exposes utilities like bulk operations, scanning, and TTL management. Key differentiators: seamless NestJS module integration with @InjectRedis and RedisService dependency injection; supports arbitrary connection names; zero-configuration setup via .env. Designed for Node.js >=14 and ships TypeScript definitions.

npm install nestjs-power-redis
INSTALL
IMPORT
SIG · NESTJS-POWER-REDIS
N
nestjs-power-redis
databasejavascriptv1.0.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RedisModule
import { RedisModule } from 'nestjs-power-redis'
import RedisModule from 'nestjs-power-redis'
Named export from the package. Default import is not supported.
InjectRedis
import { InjectRedis } from 'nestjs-power-redis'
import { InjectRedis } from '@nestjs/common'
Custom decorator provided by nestjs-power-redis, not NestJS core.
RedisService
import { RedisService } from 'nestjs-power-redis'
const RedisService = require('nestjs-power-redis').RedisService
Both ESM and CJS patterns work, but ESM import is preferred and the library is ESM-first since v1.

Register a Redis connection named 'queues' via environment variables and inject it into a service for basic get/set operations.

// .env REDIS_QUEUES_HOST=127.0.0.1 REDIS_QUEUES_PORT=6379 REDIS_QUEUES_PASSWORD= REDIS_QUEUES_DATABASE=0 // app.module.ts import { Module } from '@nestjs/common'; import { RedisModule } from 'nestjs-power-redis'; @Module({ imports: [ RedisModule.forRoot(['queues']) ], }) export class AppModule {} // my.service.ts import { Injectable } from '@nestjs/common'; import { InjectRedis, RedisService } from 'nestjs-power-redis'; @Injectable() export class MyService { constructor( @InjectRedis('queues') private readonly redis: RedisService, ) {} async test() { await this.redis.setOne('key', 'value'); const val = await this.redis.getOne('key'); return val; } }
Debug
Known issues
breakingEnvironment variable format changed: from REDIS_CONNECTION_<NAME>_HOST to REDIS_<NAME>_HOST in version 1.0.0.
fix
Rename env vars to use REDIS_<NAME>_HOST format (e.g., REDIS_QUEUES_HOST).
affects: <1.0.0
deprecatedUsing 'RedisModule.forRootAsync' with factory provider is deprecated; prefer static 'RedisModule.forRoot' with env vars.
fix
Switch to RedisModule.forRoot(['name1', 'name2']) and configure via environment variables.
affects: >=0.5.0
gotchaConnection names must contain only Latin characters, hyphens, and underscores. Special symbols or spaces will cause silent failures.
fix
Ensure connection names follow the regex [a-zA-Z_-]+.
affects: >=0.1.0
gotchaTLS fields are optional but if provided, all three (REDIS_<NAME>_TLS_CRT, REDIS_<NAME>_TLS_KEY, REDIS_<NAME>_TLS_CA_CRT) must be set; partial TLS config is ignored without warning.
fix
Set all three TLS env vars or none.
affects: >=1.0.0
deprecatedThe RedisService.set() method (without suffix) is deprecated; use setOne() instead.
fix
Replace redis.set() with redis.setOne().
affects: >=1.0.0
Errors
Common errors & fixes
RedisModule is not a function
Importing RedisModule as default export when it is a named export.
fix
Use `import { RedisModule } from 'nestjs-power-redis'` instead of `import RedisModule from ...`.
Cannot find module 'nestjs-power-redis' or its corresponding type declarations.
Missing installation or TypeScript not resolving the package.
fix
Run `npm install nestjs-power-redis` and ensure tsconfig.json includes `"moduleResolution": "node"`.
Connection refused: connect ECONNREFUSED 127.0.0.1:6379
Redis server not running or wrong host/port configured in environment variables.
fix
Start Redis server or update REDIS_<NAME>_HOST and REDIS_<NAME>_PORT in .env.
Upgrade
Version history
1.0.18latest on npm
Audit
Dependencies
@nestjs/commonrequiredPeer dependency required for NestJS module and decorator support.
power-redisrequiredCore Redis wrapper library providing the actual Redis client functionality.
Agent activity
2 hits · last 30 days
node
2
Resources
nestjs-power-redis — npm install nestjs-power-redis · libregistry