@tc-libs/sse 3.6.0 → 3.6.1

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 +48 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,53 @@
1
- # sse
1
+ # @tc-libs/sse
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Hub semplice per Server-Sent Events.
4
4
 
5
- ## Building
5
+ Espone:
6
6
 
7
- Run `nx build sse` to build the library.
7
+ - `SseModule`
8
+ - `SseHubService`
9
+ - `SseController`
8
10
 
9
- ## Running unit tests
11
+ ## Cosa fa
10
12
 
11
- Run `nx test sse` to execute the unit tests via [Jest](https://jestjs.io).
13
+ `SseHubService` mantiene una mappa di client connessi e permette di:
14
+
15
+ - aggiungere un client con `addClient`
16
+ - rimuoverlo con `removeClient`
17
+ - inviare eventi a tutti con `broadcast`
18
+ - contare le connessioni con `count`
19
+
20
+ ## Uso del service
21
+
22
+ ```ts
23
+ this.sseHubService.broadcast('job.completed', {
24
+ jobId: '123',
25
+ status: 'done',
26
+ });
27
+ ```
28
+
29
+ Quando un client si collega riceve subito un evento `hello`.
30
+
31
+ ## Endpoint incluso
32
+
33
+ Il controller esporta un endpoint SSE su `GET /sse`:
34
+
35
+ ```ts
36
+ @Sse('sse')
37
+ stream(@Req() req: Request): Observable<MessageEvent>
38
+ ```
39
+
40
+ Alla chiusura della connessione il client viene rimosso automaticamente.
41
+
42
+ ## Note operative
43
+
44
+ - Il modulo e `@Global()`.
45
+ - Il package non gestisce autenticazione o stanze/canali.
46
+ - Il package `request` esclude esplicitamente l'endpoint SSE dal timeout globale.
47
+
48
+ ## Sviluppo
49
+
50
+ ```bash
51
+ nx build sse
52
+ nx test sse
53
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tc-libs/sse",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "dependencies": {
5
5
  "@nestjs/common": "^11.0.12",
6
6
  "@nestjs/throttler": "^6.4.0",