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 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 High-Performance Hybrid HTTP Runtime for Node.js</strong>
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
  [![npm version](https://img.shields.io/npm/v/qhttpx.svg?style=flat-square)](https://www.npmjs.com/package/qhttpx)
15
14
  [![Downloads](https://img.shields.io/npm/dm/qhttpx.svg?style=flat-square)](https://www.npmjs.com/package/qhttpx)
16
- [![Website](https://img.shields.io/badge/website-qhttpx.gridrr.com-blueviolet.svg?style=flat-square)](https://qhttpx.gridrr.com)
17
15
  [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/Quantam-Open-Source/qhttpx/blob/main/LICENSE)
18
16
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
19
17
  [![TypeScript](https://img.shields.io/badge/Written%20in-TypeScript-blue?style=flat-square)](https://www.typescriptlang.org)
18
+ [![Production Ready](https://img.shields.io/badge/Production-Ready-brightgreen.svg?style=flat-square)](#)
20
19
 
21
20
  </div>
22
21
 
23
22
  <br />
24
23
 
25
- **QHTTPX** is a next-generation, concurrency-native HTTP runtime designed to outperform traditional frameworks like Express and Fastify. It is built from the ground up to handle extreme concurrency on low-resource hardware by leveraging a unified async scheduler for requests, streams, and background tasks.
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** | **⚡ Hybrid (C++ / JS)** | JS | JS | JS |
45
+ | **Core Runtime** | **⚡ Pure TypeScript** | JS | JS | JS |
49
46
  | **Request Fusion** | **✅ Native** | ❌ | ❌ | ❌ |
50
47
  | **DDoS Protection** | **✅ Built-in (Aegis)** | ❌ | ❌ | ❌ |
51
- | **JSON Serialization** | **✅ Zero-Copy (C++)** | Schema-based | Slow | Slow |
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 Advanced Way (Custom Configuration)
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 { createHttpApp } from "qhttpx";
203
+ import { app } from 'qhttpx';
197
204
 
198
- const app = createHttpApp({
199
- enableRequestFusion: true, // Enable coalescing
200
- maxBodySize: "1mb"
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("/users", ({ json, query }) => {
204
- const { page } = query;
205
- return { page };
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qhttpx",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "gypfile": false,
5
5
  "description": "The Ultra-Fast HTTP Framework for Node.js",
6
6
  "main": "dist/src/index.js",
@@ -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 readonly enabled;
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;
@@ -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.enabled = options.enabled ?? true;
15
+ this._enabled = options.enabled ?? true;
16
16
  }
17
17
  get isEnabled() {
18
- return this.enabled;
18
+ return this._enabled;
19
+ }
20
+ setEnabled(value) {
21
+ this._enabled = value;
19
22
  }
20
23
  onRequestStart() {
21
- if (!this.enabled) {
24
+ if (!this._enabled) {
22
25
  return;
23
26
  }
24
27
  this.inFlightRequests += 1;
25
28
  }
26
29
  onRequestEnd(durationMs, statusCode) {
27
- if (!this.enabled) {
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.enabled) {
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.enabled) {
80
+ if (!this._enabled) {
78
81
  return;
79
82
  }
80
83
  if (!Number.isFinite(durationMs) || durationMs < 0) {
@@ -1033,14 +1033,7 @@ class QHTTPX {
1033
1033
  }
1034
1034
  metrics(enable = true) {
1035
1035
  this.options.metricsEnabled = enable;
1036
- // Metrics instance checks this.options.metricsEnabled in some places?
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) {