ultimate-express 1.0.4 → 1.0.6
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 +9 -8
- package/package.json +1 -1
- package/src/request.js +14 -1
- package/src/response.js +2 -2
package/README.md
CHANGED
|
@@ -23,14 +23,15 @@ Similar projects based on uWebSockets:
|
|
|
23
23
|
|
|
24
24
|
Tested using [wrk](https://github.com/wg/wrk) (`-d 60 -t 1 -c 200`). Etag was disabled in both Express and µExpress. Tested on Ubuntu 22.04, Node.js 20.17.0, AMD Ryzen 5 3600, 64GB RAM.
|
|
25
25
|
|
|
26
|
-
| Test | Path
|
|
27
|
-
| --------------------------- |
|
|
28
|
-
| routing/simple-routes | /
|
|
29
|
-
| routing/lot-of-routes | /999
|
|
30
|
-
| routing/some-middlewares | /90
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
26
|
+
| Test | Path | Express req/sec | µExpress req/sec | Express throughput | µExpress throughput | µExpress speedup |
|
|
27
|
+
| --------------------------- | ----------------- | --------------- | ---------------- | ------------------ | ------------------- | ---------------- |
|
|
28
|
+
| routing/simple-routes | / | 10.90k | 70.10k | 2.04 MB/sec | 11.57 MB/sec | **6.43X** |
|
|
29
|
+
| routing/lot-of-routes | /999 | 4.66k | 51.58k | 0.85 MB/sec | 8.07 MB/sec | **11.07X** |
|
|
30
|
+
| routing/some-middlewares | /90 | 10.18k | 66.97k | 1.81 MB/sec | 10.42 MB/sec | **6.58X** |
|
|
31
|
+
| routers/nested-routers | /abccc/nested/ddd | 10.25k | 50.98k | 1.83 MB/sec | 7.98 MB/sec | **4.97X** |
|
|
32
|
+
| middlewares/express-static | /static/index.js | 7.52k | 31.08k | 6.92 MB/sec | 26.48 MB/sec | **4.13X** |
|
|
33
|
+
| engines/ejs | /test | 5.92k | 14.43k | 2.40 MB/sec | 5.53 MB/sec | **2.44X** |
|
|
34
|
+
| middlewares/body-urlencoded | /abc (POST) | 7.90k | 29.90k | 1.64 MB/sec | 5.36 MB/sec | **3.78X** |
|
|
34
35
|
|
|
35
36
|
Also tested on a real-world application with templates, static files and dynamic pages with data from database ([nekoweb.org](https://nekoweb.org)), and showed about 1.5-4X speedup in requests per second.
|
|
36
37
|
|
package/package.json
CHANGED
package/src/request.js
CHANGED
|
@@ -42,6 +42,7 @@ module.exports = class Request extends Readable {
|
|
|
42
42
|
}
|
|
43
43
|
this.method = req.getMethod().toUpperCase();
|
|
44
44
|
this.params = {};
|
|
45
|
+
this.rawIp = Buffer.from(this._res.getRemoteAddressAsText()).toString();
|
|
45
46
|
|
|
46
47
|
this._gotParams = new Set();
|
|
47
48
|
this._stack = [];
|
|
@@ -124,10 +125,22 @@ module.exports = class Request extends Readable {
|
|
|
124
125
|
return index !== -1 ? host.slice(0, index) : host;
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
get httpVersion() {
|
|
129
|
+
return '1.1';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get httpVersionMajor() {
|
|
133
|
+
return 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get httpVersionMinor() {
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
127
140
|
get ip() {
|
|
128
141
|
const trust = this.app.get('trust proxy fn');
|
|
129
142
|
if(!trust) {
|
|
130
|
-
return
|
|
143
|
+
return this.rawIp;
|
|
131
144
|
}
|
|
132
145
|
return proxyaddr(this, trust);
|
|
133
146
|
}
|
package/src/response.js
CHANGED
|
@@ -185,7 +185,7 @@ module.exports = class Response extends Writable {
|
|
|
185
185
|
body = '';
|
|
186
186
|
} else if(typeof body === 'object') {
|
|
187
187
|
if(!(body instanceof ArrayBuffer)) {
|
|
188
|
-
|
|
188
|
+
return this.json(body);
|
|
189
189
|
}
|
|
190
190
|
} else if(typeof body === 'number') {
|
|
191
191
|
if(arguments[1]) {
|
|
@@ -421,7 +421,7 @@ module.exports = class Response extends Writable {
|
|
|
421
421
|
if(!name) {
|
|
422
422
|
name = Path.basename(path);
|
|
423
423
|
}
|
|
424
|
-
if(!opts.root) {
|
|
424
|
+
if(!opts.root && !isAbsolute(path)) {
|
|
425
425
|
opts.root = process.cwd();
|
|
426
426
|
}
|
|
427
427
|
|