http-request-manager 22.0.4 → 22.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.
package/README.md
CHANGED
|
@@ -25,15 +25,51 @@ This README is the main documentation hub for the library. Detailed service guid
|
|
|
25
25
|
| **🗄️ Database Queries** | MySQL-syntax SQL queries on IndexedDB — the recommended way to query data | [`DexieSqlService`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/SQL_DIXIE_README.md) | Uses the same service |
|
|
26
26
|
| **⚡ Utility Functions** | JSON handling, encryption, headers, validation, logging | [`UtilsService`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/UTILS_README.md), [`Encryption`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/ENCRYPTION_README.md), [`Logger`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/LOGGER_README.md) | Uses the same utility layer |
|
|
27
27
|
| **🔧 Utility Services** | Headers, path/query, merging, base request classes | [`Utility Services`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/UTILS_SERVICES_README.md) | Internal and helper services |
|
|
28
|
+
| **🖥️ Node.js WS Server** | Companion [`ws-request-manager`](https://www.npmjs.com/package/ws-request-manager) Node.js package — pluggable auth, IP rate limiting, channels, heartbeat, message replay | [`WebSocket Server Guide`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/WS_SERVER_README.md) | Same protocol on both sides |
|
|
28
29
|
|
|
29
30
|
### Key Benefits
|
|
30
31
|
|
|
31
32
|
- ✅ **Type-Safe** - Full TypeScript support with generics
|
|
32
33
|
- ✅ **Offline-First** - Built-in IndexedDB caching
|
|
33
|
-
- ✅ **Real-Time Ready** - Seamless WebSocket integration
|
|
34
|
+
- ✅ **Real-Time Ready** - Seamless WebSocket integration with companion Node.js server
|
|
34
35
|
- ✅ **Secure** - AES & RSA encryption support for sensitive data
|
|
35
36
|
- ✅ **Scalable** - ComponentStore-based architecture
|
|
36
37
|
- ✅ **Flexible** - Works with Observables or Signals
|
|
38
|
+
- ✅ **Pluggable Auth on Server** - You control auth (API key, JWT, cookie, BFF session) and rate limits on the Node.js side
|
|
39
|
+
|
|
40
|
+
### 🖥️ Server-Side Companion — `ws-request-manager`
|
|
41
|
+
|
|
42
|
+
The frontend `http-request-manager` speaks the full WebSocket protocol implemented by the Node.js package [`ws-request-manager`](https://www.npmjs.com/package/ws-request-manager). The server package is **deliberately thin** — it does **not** implement any auth strategy. Instead, you provide a `WsAuthFn` (an async function) and the library calls it on every WebSocket upgrade.
|
|
43
|
+
|
|
44
|
+
**Quick start:**
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// server.js
|
|
48
|
+
const express = require('express');
|
|
49
|
+
const http = require('http');
|
|
50
|
+
const { register, registerServer, destroy, noAuth } = require('ws-request-manager');
|
|
51
|
+
|
|
52
|
+
const app = express();
|
|
53
|
+
app.use(express.json());
|
|
54
|
+
|
|
55
|
+
async function start() {
|
|
56
|
+
await register(app, noAuth); // mounts /ws/channels, /ws/connections, /ws/broadcast
|
|
57
|
+
const server = http.createServer(app);
|
|
58
|
+
await registerServer(server, noAuth); // attaches WS upgrade handler at /ws
|
|
59
|
+
server.listen(3000);
|
|
60
|
+
process.on('SIGTERM', async () => { await destroy(); server.close(); });
|
|
61
|
+
}
|
|
62
|
+
start();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Swap `noAuth` for a custom `WsAuthFn` to gate access. Common patterns:
|
|
66
|
+
|
|
67
|
+
- `createApiKeyAuth(process.env.STATIC_API_KEY)` — static API key
|
|
68
|
+
- `createJwtAuth(process.env.JWT_SECRET_KEY)` — JWT (re-use your HTTP API's secret)
|
|
69
|
+
- `createCookieAuth(validateSession)` — BFF session cookie
|
|
70
|
+
- `createRateLimitedAuth(authFn, { maxFailures: 10, blockDurationMs: 300_000 })` — IP-based rate limiting wrapper
|
|
71
|
+
|
|
72
|
+
👉 **Full guide:** [`WS_SERVER_README.md`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/WS_SERVER_README.md) — covers configuration (env vars), auth patterns, rate limiting, full message protocol reference, HTTP REST routes, and the end-to-end BFF setup.
|
|
37
73
|
|
|
38
74
|
Note on clearing persisted data:
|
|
39
75
|
|
|
@@ -72,6 +108,7 @@ See the full SQL syntax reference: [`DexieSqlService Guide`](https://github.com/
|
|
|
72
108
|
| **🏷️ Channel Architecture** | SYS-, PUB-, MES- channel prefixes | [`WebSocket Guide`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/ADVANCED_WEBSOCKET.md#channels) |
|
|
73
109
|
| **🔌 Singleton WebSocket** | Single connection across ALL instances | [`WebSocket Guide`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/ADVANCED_WEBSOCKET.md#singleton) |
|
|
74
110
|
| **✨ Unified Message Service** | Type-safe WebSocket messaging with auto prefixes | [`WebSocket Message Service`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/WEBSOCKET_MESSAGE_SERVICE.md) |
|
|
111
|
+
| **🖥️ Node.js WS Server** | Companion `ws-request-manager` package for Node.js — pluggable auth, rate limiting, channels, heartbeat | [`WebSocket Server Guide`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/WS_SERVER_README.md) ([npm](https://www.npmjs.com/package/ws-request-manager)) |
|
|
75
112
|
| **🚀 Batch Requests** | Execute multiple HTTP requests with sequential/parallel modes | [`Batch Request Guide`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/BATCH_REQUEST_README.md) |
|
|
76
113
|
| **📝 Message Tracking** | Guaranteed delivery with gap detection | [`Message Tracker`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/MESSAGE_TRACKER_README.md) |
|
|
77
114
|
| **🔍 Debug Logging** | Context-aware logging with dev/prod modes | [`Logger Service`](https://github.com/micheleboni/npm-angular/tree/main/projects/http-request-manager/src/docs/LOGGER_README.md) |
|