nestjs-power-queues 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +167 -2
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,2 +1,167 @@
1
- # NestjsPowerQueues
2
- ## NestJS wrapper for PowerQueues.
1
+ # nestjs-power-queues — Secure, Scalable & Production‑Ready power-queues Integration for NestJS
2
+
3
+ This module is a **dedicated, production-ready NestJS wrapper around `power-queues`** — a high‑performance Redis abstraction layer for Node.js.
4
+
5
+ It is a **structured, type-safe, and feature-rich integration** designed specifically to bring all the power of `power-queues` into the NestJS ecosystem with zero friction.
6
+
7
+ <p align="center">
8
+ <img src="https://img.shields.io/badge/redis-streams-red?logo=redis" />
9
+ <img src="https://img.shields.io/badge/nodejs-queue-green?logo=node.js" />
10
+ <img src="https://img.shields.io/badge/typescript-ready-blue?logo=typescript" />
11
+ <img src="https://img.shields.io/badge/license-MIT-lightgrey" />
12
+ <img src="https://img.shields.io/badge/nestjs-support-ea2845?logo=nestjs" />
13
+ <img src="https://img.shields.io/badge/status-production-success" />
14
+ </p>
15
+
16
+ ---
17
+
18
+ ## 📚 Documentation
19
+
20
+ Full documentation is available here:
21
+ 👉 **https://nestjs-power-queues.docs.ihor.bielchenko.com**
22
+
23
+ ---
24
+
25
+ # 📦 Installation
26
+
27
+ ``` bash
28
+ npm install nestjs-power-queues
29
+ ```
30
+ OR
31
+ ```bash
32
+ yarn add nestjs-power-queues
33
+ ```
34
+ ---
35
+
36
+ # 🧪 Quick Start Example
37
+
38
+ ## For example, you need to specify 2 connections: `queues1` and `queues2`
39
+
40
+ ### 1. 🔐 Environment Variables (power-redis -Friendly)
41
+
42
+ Everything is configured using environment variables:
43
+
44
+ ```env
45
+ REDIS_<NAME>_HOST=127.0.0.1
46
+ REDIS_<NAME>_PORT=6379
47
+ REDIS_<NAME>_PASSWORD=pass
48
+ REDIS_<NAME>_DATABASE=0
49
+
50
+ # TLS
51
+ REDIS_<NAME>_TLS_CRT=/etc/ssl/client.crt
52
+ REDIS_<NAME>_TLS_KEY=/etc/ssl/client.key
53
+ REDIS_<NAME>_TLS_CA_CRT=/etc/ssl/ca.crt
54
+ ```
55
+
56
+ Instead of `<NAME>` you need to specify a custom connection name and then specify these names in `QueueModule.forRoot` (allowed in lowercase).
57
+ For example:
58
+
59
+ ```env
60
+ REDIS_QUEUES1_HOST=127.0.0.1
61
+ REDIS_QUEUES1_PORT=6379
62
+ REDIS_QUEUES1_PASSWORD=
63
+ REDIS_QUEUES1_DATABASE=0
64
+
65
+ REDIS_QUEUES2_HOST=127.0.0.1
66
+ REDIS_QUEUES2_PORT=6379
67
+ REDIS_QUEUES2_PASSWORD=
68
+ REDIS_QUEUES2_DATABASE=0
69
+ ```
70
+
71
+ TLS fields are optional.
72
+
73
+ ---
74
+
75
+ ### 2. Register module with multiple Redis clients
76
+
77
+ ```ts
78
+ import { QueueModule } from 'nestjs-power-queues';
79
+
80
+ @Module({
81
+ imports: [
82
+ QueueModule.forRoot([ 'queues1', 'queues2' ]),
83
+ ],
84
+ })
85
+ export class AppModule {}
86
+ ```
87
+
88
+ ---
89
+
90
+ ### 3. Inject in a service
91
+
92
+ ```ts
93
+ import { Injectable } from '@nestjs/common';
94
+ import {
95
+ InjectQueue,
96
+ QueueService,
97
+ } from 'nestjs-power-queues';
98
+
99
+ @Injectable()
100
+ export class MyService {
101
+ constructor(
102
+ @InjectQueue('queues1') private readonly queueService1: QueueService,
103
+ @InjectQueue('queues2') private readonly queueService2: QueueService,
104
+ ) {}
105
+
106
+ async test() {
107
+ await this.queueService1.addTasks('example:jobs', [
108
+ { payload },
109
+ ]);
110
+ }
111
+ }
112
+ ```
113
+
114
+ ### 3. Create job processor
115
+
116
+ ```ts
117
+ import { Injectable } from '@nestjs/common';
118
+ import {
119
+ InjectRedis,
120
+ RedisService,
121
+ } from 'nestjs-power-redis';
122
+ import { QueueService } from 'nestjs-power-queues';
123
+
124
+ @Injectable()
125
+ export class MyService extends QueueService {
126
+ public readonly stream: string = `example:jobs`;
127
+ public readonly workerBatchTasksCount: number = 8192;
128
+ public readonly runOnInit: boolean = true;
129
+ public readonly executeBatchAtOnce: boolean = true;
130
+
131
+ constructor(
132
+ @InjectRedis('queues1') public readonly redisService: RedisService,
133
+ ) {}
134
+
135
+ async onExecute(id, payload) {
136
+ // business-logic
137
+ }
138
+ }
139
+ ```
140
+
141
+ The `runOnInit` parameter determines whether queue processing should start immediately after the application starts.
142
+
143
+ ---
144
+
145
+ ## 🏗️ How It Works Internally
146
+
147
+ ### queueRoot()
148
+ Loads all Redis configurations based on environment variables, applies TLS if present, and sets reconnection strategies.
149
+
150
+ ### RedisModule.forRoot()
151
+ Creates dynamic providers for each Redis connection:
152
+ ```
153
+ RedisQueue_queues1
154
+ RedisQueue_queues2
155
+ ```
156
+
157
+ These providers are available through:
158
+ ```ts
159
+ @InjectQueue('queues1')
160
+ @InjectQueue('queues2')
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 📜 License
166
+
167
+ MIT - free for commercial and private use.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nestjs-power-queues",
3
- "version": "1.0.11",
4
- "description": "NestJS wrapper for PowerQueues.",
3
+ "version": "1.0.13",
4
+ "description": "High-performance Redis Streams queue integration for NestJS based on power-queues.",
5
5
  "author": "ihor-bielchenko",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -88,7 +88,7 @@
88
88
  "@nestjs-labs/nestjs-ioredis": "^11.0.4",
89
89
  "@nestjs/common": "^11.1.8",
90
90
  "full-utils": "^2.0.5",
91
- "nestjs-power-redis": "^1.0.8",
92
- "power-queues": "^2.0.16"
91
+ "nestjs-power-redis": "^1.0.9",
92
+ "power-queues": "^2.0.17"
93
93
  }
94
94
  }