qhttpx 2.0.0 → 2.1.0
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 +29 -33
- package/dist/package.json +1 -1
- package/dist/src/core/metrics.d.ts +2 -1
- package/dist/src/core/metrics.js +9 -6
- package/dist/src/core/server.js +1 -8
- package/docs/API_REFERENCE.md +749 -0
- package/docs/MIGRATION_1.9_TO_2.0.md +495 -0
- package/docs/PRODUCTION_DEPLOYMENT.md +798 -0
- package/docs/SECURITY.md +876 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
<img src="https://raw.githubusercontent.com/Quantam-Open-Source/qhttpx/main/assets/logo.svg" alt="QHTTPX Logo" width="200" height="200" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
<div align="center">
|
|
7
|
-
<strong>The
|
|
6
|
+
<strong>The Ultra-Fast HTTP Framework for Node.js</strong>
|
|
8
7
|
</div>
|
|
9
8
|
|
|
10
9
|
<br />
|
|
@@ -13,18 +12,16 @@
|
|
|
13
12
|
|
|
14
13
|
[](https://www.npmjs.com/package/qhttpx)
|
|
15
14
|
[](https://www.npmjs.com/package/qhttpx)
|
|
16
|
-
[](https://qhttpx.gridrr.com)
|
|
17
15
|
[](https://github.com/Quantam-Open-Source/qhttpx/blob/main/LICENSE)
|
|
18
16
|
[](http://makeapullrequest.com)
|
|
19
17
|
[](https://www.typescriptlang.org)
|
|
18
|
+
[](#)
|
|
20
19
|
|
|
21
20
|
</div>
|
|
22
21
|
|
|
23
22
|
<br />
|
|
24
23
|
|
|
25
|
-
**
|
|
26
|
-
|
|
27
|
-
It is not just a web framework; it is an **Operating System for your API**.
|
|
24
|
+
**QHttpX** is a high-performance HTTP framework for Node.js. Minimal API. Maximum performance. Built-in features like Request Fusion, WebSockets, and rate limiting.
|
|
28
25
|
|
|
29
26
|
---
|
|
30
27
|
|
|
@@ -45,10 +42,10 @@ Most Node.js frameworks rely on the event loop blindly. QHTTPX introduces a **Co
|
|
|
45
42
|
|
|
46
43
|
| Feature | **QHTTPX** | Fastify | Express | Hono |
|
|
47
44
|
| :--- | :---: | :---: | :---: | :---: |
|
|
48
|
-
| **Core Runtime** | **⚡
|
|
45
|
+
| **Core Runtime** | **⚡ Pure TypeScript** | JS | JS | JS |
|
|
49
46
|
| **Request Fusion** | **✅ Native** | ❌ | ❌ | ❌ |
|
|
50
47
|
| **DDoS Protection** | **✅ Built-in (Aegis)** | ❌ | ❌ | ❌ |
|
|
51
|
-
| **JSON Serialization** | **✅
|
|
48
|
+
| **JSON Serialization** | **✅ Optimized Fast-Path** | Schema-based | Slow | Slow |
|
|
52
49
|
| **Concurrency Model** | **✅ Async Scheduler** | Event Loop | Event Loop | Event Loop |
|
|
53
50
|
| **Rate Limiting** | **✅ Zero-Overhead** | Plugin | Middleware | Middleware |
|
|
54
51
|
| **Routing Algorithm** | **✅ Optimized Radix** | Radix Tree | Linear/Regex | RegExp/Trie |
|
|
@@ -129,6 +126,17 @@ Everything you need, built-in but modular.
|
|
|
129
126
|
|
|
130
127
|
---
|
|
131
128
|
|
|
129
|
+
## 📚 Documentation
|
|
130
|
+
|
|
131
|
+
New to QHttpX? Start here:
|
|
132
|
+
|
|
133
|
+
- **[API Reference](./docs/API_REFERENCE.md)** - Complete API documentation with examples
|
|
134
|
+
- **[Security Guide](./docs/SECURITY.md)** - Production security best practices
|
|
135
|
+
- **[Production Deployment](./docs/PRODUCTION_DEPLOYMENT.md)** - Deploy to VPS, Docker, or Kubernetes
|
|
136
|
+
- **[Migration Guide](./docs/MIGRATION_1.9_TO_2.0.md)** - Migrate from v1.9.4 to v2.0+
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
132
140
|
## 📦 Installation
|
|
133
141
|
|
|
134
142
|
```bash
|
|
@@ -188,24 +196,26 @@ app.start(3000).then(() => console.log('Running on http://localhost:3000'));
|
|
|
188
196
|
|
|
189
197
|
Run with: `node index.js`
|
|
190
198
|
|
|
191
|
-
### 3. The
|
|
192
|
-
|
|
193
|
-
When you need specific configuration options or multiple instances.
|
|
199
|
+
### 3. The Fluent Way (Advanced Configuration)
|
|
200
|
+
Use the chainable API to configure advanced features like Request Fusion, Metrics, and Body Limits.
|
|
194
201
|
|
|
195
202
|
```typescript
|
|
196
|
-
import {
|
|
203
|
+
import { app } from 'qhttpx';
|
|
197
204
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
});
|
|
205
|
+
app.fusion(true) // Enable Request Coalescing
|
|
206
|
+
.metrics(true) // Enable Prometheus-style metrics
|
|
207
|
+
.bodyLimit(1024 * 1024)// Set 1MB body limit
|
|
208
|
+
.security({ cors: true });
|
|
202
209
|
|
|
203
|
-
app.get(
|
|
204
|
-
|
|
205
|
-
return
|
|
210
|
+
app.get('/heavy-compute', async () => {
|
|
211
|
+
// If 1000 users hit this at once, it executes ONLY ONCE
|
|
212
|
+
return await db.query('SELECT * FROM heavy_table');
|
|
206
213
|
});
|
|
214
|
+
|
|
215
|
+
app.start(3000);
|
|
207
216
|
```
|
|
208
217
|
|
|
218
|
+
|
|
209
219
|
---
|
|
210
220
|
|
|
211
221
|
## 📚 Documentation
|
|
@@ -223,21 +233,7 @@ Detailed guides for every feature of QHTTPX:
|
|
|
223
233
|
|
|
224
234
|
---
|
|
225
235
|
|
|
226
|
-
## 📊 Benchmarks
|
|
227
236
|
|
|
228
|
-
Benchmarks comparing **QHTTPX v1.8.6** against popular Node.js frameworks.
|
|
229
|
-
*(Run on local environment: Windows, 100 connections, 10 pipelining, 40s duration. Average of 2 runs, taking the second result.)*
|
|
230
|
-
|
|
231
|
-
| Framework | Req/Sec | Latency (Avg) | Throughput |
|
|
232
|
-
| :--- | :--- | :--- | :--- |
|
|
233
|
-
| **Fastify** | 16,050 | 256.78 ms | 3.00 Mb/s |
|
|
234
|
-
| **QHTTPX** | **14,179** | **291.13 ms** | **3.02 Mb/s** |
|
|
235
|
-
| **Hono** | 14,176 | 294.09 ms | 2.43 Mb/s |
|
|
236
|
-
| **Express** | 10,450 | 407.12 ms | 1.94 Mb/s |
|
|
237
|
-
|
|
238
|
-
> **Note**: QHTTPX achieves comparable throughput to Fastify while offering advanced features like **Request Fusion** (deduplication) which can significantly reduce database load in real-world scenarios.
|
|
239
|
-
|
|
240
|
-
---
|
|
241
237
|
|
|
242
238
|
## 🤝 Ecosystem Compatibility
|
|
243
239
|
|
package/dist/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export declare class Metrics {
|
|
|
29
29
|
private readonly fusion?;
|
|
30
30
|
private readonly latencies;
|
|
31
31
|
private readonly maxLatencies;
|
|
32
|
-
private
|
|
32
|
+
private _enabled;
|
|
33
33
|
private totalRequests;
|
|
34
34
|
private inFlightRequests;
|
|
35
35
|
private totalErrors;
|
|
@@ -39,6 +39,7 @@ export declare class Metrics {
|
|
|
39
39
|
enabled?: boolean;
|
|
40
40
|
}, taskEngine?: TaskEngine, fusion?: RequestFusion);
|
|
41
41
|
get isEnabled(): boolean;
|
|
42
|
+
setEnabled(value: boolean): void;
|
|
42
43
|
onRequestStart(): void;
|
|
43
44
|
onRequestEnd(durationMs: number, statusCode: number): void;
|
|
44
45
|
onTimeout(): void;
|
package/dist/src/core/metrics.js
CHANGED
|
@@ -12,19 +12,22 @@ class Metrics {
|
|
|
12
12
|
this.taskEngine = taskEngine;
|
|
13
13
|
this.fusion = fusion;
|
|
14
14
|
this.maxLatencies = options.maxLatencies ?? 1000;
|
|
15
|
-
this.
|
|
15
|
+
this._enabled = options.enabled ?? true;
|
|
16
16
|
}
|
|
17
17
|
get isEnabled() {
|
|
18
|
-
return this.
|
|
18
|
+
return this._enabled;
|
|
19
|
+
}
|
|
20
|
+
setEnabled(value) {
|
|
21
|
+
this._enabled = value;
|
|
19
22
|
}
|
|
20
23
|
onRequestStart() {
|
|
21
|
-
if (!this.
|
|
24
|
+
if (!this._enabled) {
|
|
22
25
|
return;
|
|
23
26
|
}
|
|
24
27
|
this.inFlightRequests += 1;
|
|
25
28
|
}
|
|
26
29
|
onRequestEnd(durationMs, statusCode) {
|
|
27
|
-
if (!this.
|
|
30
|
+
if (!this._enabled) {
|
|
28
31
|
return;
|
|
29
32
|
}
|
|
30
33
|
this.totalRequests += 1;
|
|
@@ -37,7 +40,7 @@ class Metrics {
|
|
|
37
40
|
this.recordLatency(durationMs);
|
|
38
41
|
}
|
|
39
42
|
onTimeout() {
|
|
40
|
-
if (!this.
|
|
43
|
+
if (!this._enabled) {
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
this.totalTimeouts += 1;
|
|
@@ -74,7 +77,7 @@ class Metrics {
|
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
recordLatency(durationMs) {
|
|
77
|
-
if (!this.
|
|
80
|
+
if (!this._enabled) {
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
83
|
if (!Number.isFinite(durationMs) || durationMs < 0) {
|
package/dist/src/core/server.js
CHANGED
|
@@ -1033,14 +1033,7 @@ class QHTTPX {
|
|
|
1033
1033
|
}
|
|
1034
1034
|
metrics(enable = true) {
|
|
1035
1035
|
this.options.metricsEnabled = enable;
|
|
1036
|
-
|
|
1037
|
-
// The Metrics class is initialized in constructor.
|
|
1038
|
-
// We might need to update the metrics instance.
|
|
1039
|
-
// But looking at Metrics class, it takes options in constructor.
|
|
1040
|
-
// However, we can probably update the internal state if needed.
|
|
1041
|
-
// For now, let's assume setting options is enough or we might need to expose a method on Metrics.
|
|
1042
|
-
// Re-initializing metrics might be complex.
|
|
1043
|
-
// Let's assume the user calls this before start.
|
|
1036
|
+
this._metrics.setEnabled(enable);
|
|
1044
1037
|
return this;
|
|
1045
1038
|
}
|
|
1046
1039
|
error(status, message, details) {
|