@nestjs-redis/socket.io-adapter 0.11.1 → 0.11.2

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 +13 -70
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # @nestjs-redis/socket.io-adapter
6
6
 
7
- Redis-powered Socket.IO adapter for NestJS enabling scalable WebSocket connections across multiple instances.
7
+ Redis-powered Socket.IO adapter for NestJS
8
8
 
9
9
  [![npm version](https://badge.fury.io/js/%40nestjs-redis%2Fsocket.io-adapter.svg)](https://www.npmjs.com/package/@nestjs-redis/socket.io-adapter)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/@nestjs-redis/socket.io-adapter.svg)](https://www.npmjs.com/package/@nestjs-redis/socket.io-adapter)
@@ -18,26 +18,25 @@ Redis-powered Socket.IO adapter for NestJS enabling scalable WebSocket connectio
18
18
 
19
19
  ## Features
20
20
 
21
- - **Horizontal scaling**: Connect clients to any server instance
22
- - **Redis pub/sub**: Automatic event distribution across instances
23
- - **Lifecycle management**: Redis connections are managed automatically
24
- - **Works with existing connections**: Integrates seamlessly with `@nestjs-redis/client`
25
- - **Type-safe**: Full TypeScript support
26
- - **Production-ready**: Built on the official Socket.IO Redis adapter
21
+ - Horizontal scaling with Redis pub/sub
22
+ - Works with existing `@nestjs-redis/client` connections
23
+ - Type-safe, production-ready
27
24
 
28
25
  ## Installation
29
26
 
27
+ ### Recommended: Install the complete toolkit
28
+
30
29
  ```bash
31
- npm install @nestjs-redis/socket.io-adapter
32
- # or
33
- yarn add @nestjs-redis/socket.io-adapter
34
- # or
35
- pnpm add @nestjs-redis/socket.io-adapter
30
+ npm install @nestjs-redis/kit redis
36
31
  ```
37
32
 
38
- ## Quick Start
33
+ ### Alternative: Install socket.io-adapter package only
39
34
 
40
- ### Setup with existing Redis connection (Recommended)
35
+ ```bash
36
+ npm install @nestjs-redis/socket.io-adapter redis
37
+ ```
38
+
39
+ ## Quick Start
41
40
 
42
41
  ```typescript
43
42
  // app.module.ts
@@ -103,62 +102,6 @@ async function bootstrap() {
103
102
  }
104
103
  ```
105
104
 
106
- ## The Problem
107
-
108
- When scaling your NestJS application horizontally with multiple instances, WebSocket connections become a challenge. By default, Socket.IO connections are tied to a single server instance, which means:
109
-
110
- - Events sent from one server instance won't reach clients connected to other instances
111
- - Real-time features break when users connect to different servers
112
- - Load balancing becomes complex as you need sticky sessions
113
-
114
- ## The Solution
115
-
116
- This package provides a Redis-backed Socket.IO adapter that uses Redis pub/sub to synchronize events across all server instances. When a server emits an event, it's published to Redis and distributed to all other server instances, ensuring all clients receive the event regardless of which server they're connected to.
117
-
118
- ## How It Works
119
-
120
- 1. **Redis Pub/Sub**: The adapter creates two Redis connections - one for publishing and one for subscribing
121
- 2. **Event Distribution**: When a server emits an event, it's published to a Redis channel
122
- 3. **Cross-Instance Delivery**: All server instances subscribe to the same channels and forward events to their connected clients
123
- 4. **Automatic Management**: Connection lifecycle is handled automatically by the adapter
124
-
125
- ## API
126
-
127
- ### `setupRedisAdapter(app, redisToken?)`
128
-
129
- Sets up the Redis adapter for the NestJS application.
130
-
131
- - `app`: NestJS application instance
132
- - `redisToken` (optional): Redis connection name (defaults to the default connection)
133
-
134
- ### `RedisIoAdapter`
135
-
136
- The underlying Socket.IO adapter class that handles Redis connections.
137
-
138
- ## Architecture
139
-
140
- ```
141
- ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
142
- │ Server 1 │ │ Server 2 │ │ Server 3 │
143
- │ ┌───────┐ │ │ ┌───────┐ │ │ ┌───────┐ │
144
- │ │Client │ │ │ │Client │ │ │ │Client │ │
145
- │ └───────┘ │ │ └───────┘ │ │ └───────┘ │
146
- └──────┬──────┘ └──────┬──────┘ └──────┬──────┘
147
- │ │ │
148
- └──────────────────┼──────────────────┘
149
-
150
- ┌─────▼─────┐
151
- │ Redis │
152
- │ Pub/Sub │
153
- └───────────┘
154
- ```
155
-
156
- ## Learn More
157
-
158
- - [NestJS WebSocket Adapter Documentation](https://docs.nestjs.com/websockets/adapter)
159
- - [Socket.IO Redis Adapter](https://socket.io/docs/v4/redis-adapter/)
160
- - [Redis Pub/Sub](https://redis.io/docs/manual/pubsub/)
161
-
162
105
  ## Links
163
106
 
164
107
  - Root repo: [CSenshi/nestjs-redis](https://github.com/CSenshi/nestjs-redis)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-redis/socket.io-adapter",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "license": "MIT",
5
5
  "author": "Saba Pochkhua <saba.pochkhua@gmail.com> (https://github.com/CSenshi)",
6
6
  "description": "Redis-powered Socket.IO adapter for NestJS enabling scalable WebSocket connections",