@nexusts/ws 0.9.8 → 0.9.10

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 +24 -14
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # @nexusts/ws
2
2
 
3
- > **NexusTS** — Bun-native fullstack framework
3
+ > **NexusTS WebSockets** — WebSocket gateways with Bun's built-in `Bun.serve` websocket. Rooms, broadcast, and lifecycle decorators.
4
4
 
5
- ## Description
5
+ ## Features
6
6
 
7
- WebSockets (Bun native, Node fallback via ws).
8
-
9
- @WebSocketGateway(path) / @OnWebSocketMessage() decorators. Rooms, broadcast. Runtime auto-detected (Bun primary; ws as optional peer dep on Node).
7
+ - **Bun native** uses `Bun.serve` websocket (no ws package needed)
8
+ - **Decorators** — `@WebSocketGateway(path)`, `@OnWebSocketOpen`, `@OnWebSocketMessage`, `@OnWebSocketClose`
9
+ - **Rooms** `joinRoom`, `leaveRoom`, `broadcastToRoom`
10
+ - **Cloudflare Workers** — compatible via adapter
10
11
 
11
12
  ## Install
12
13
 
@@ -26,18 +27,27 @@ bun add @nexusts/ws
26
27
 
27
28
  ## Peer dependencies
28
29
 
29
- ```bash
30
- bun add ws
31
- ```
32
-
33
- - **`ws`** ^8.18.0 — Required on Node.js. On Bun the WebSocket runtime is built in, so you can skip this dependency.
34
-
35
- Without them the module loads but its public methods throw a clear error pointing to this install command on first call.
30
+ **None.** Bun's WebSocket runtime is built in — no `ws` package needed.
36
31
 
37
- ## Usage
32
+ ## Quick start
38
33
 
39
34
  ```typescript
40
- import { /* public API */ } from "@nexusts/ws";
35
+ import { WebSocketModule, WebSocketGateway, OnWebSocketMessage } from "@nexusts/ws";
36
+ import { Module, Injectable } from "@nexusts/core";
37
+
38
+ @Injectable()
39
+ @WebSocketGateway("/chat")
40
+ class ChatGateway {
41
+ @OnWebSocketMessage("message")
42
+ onMessage(client: any, data: { text: string }) {
43
+ client.send(`Echo: ${data.text}`);
44
+ }
45
+ }
46
+
47
+ @Module({
48
+ imports: [WebSocketModule.forRoot({ gateways: [ChatGateway] })],
49
+ })
50
+ class AppModule {}
41
51
  ```
42
52
 
43
53
  See the [user guide](../../docs/user-guide/ws.md) and the [example app](../../examples/) for a working demo.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexusts/ws",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "description": "WebSockets (Bun native, Node fallback via ws)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@nexusts/core": "^0.9.8"
37
+ "@nexusts/core": "^0.9.10"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",