ultimate-express 1.0.6 → 1.0.8

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 (3) hide show
  1. package/README.md +10 -10
  2. package/package.json +2 -1
  3. package/src/response.js +14 -11
package/README.md CHANGED
@@ -23,15 +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 | 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** |
26
+ | Test | 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) | 7.90k | 29.90k | 1.64 MB/sec | 5.36 MB/sec | **3.78X** |
35
35
 
36
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.
37
37
 
@@ -229,7 +229,7 @@ In general, basically all features and options are supported. Use [Express 4.x d
229
229
  - - ✅ Range header
230
230
  - - ✅ Setting ETag header
231
231
  - - ✅ If-Match header
232
- - - ✅ If-Modified-Since header
232
+ - - ✅ If-Modified-Since header (with `options.ifModifiedSince` option)
233
233
  - - ✅ If-Unmodified-Since header
234
234
  - - ✅ If-Range header
235
235
  - ✅ res.sendStatus()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "The Ultimate Express. Fastest http server with full Express compatibility, based on uWebSockets.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -39,6 +39,7 @@
39
39
  "body-parser": "^1.20.3",
40
40
  "cookie": "^0.6.0",
41
41
  "cookie-signature": "^1.2.1",
42
+ "encodeurl": "^2.0.0",
42
43
  "etag": "^1.8.1",
43
44
  "fresh": "^0.5.2",
44
45
  "mime-types": "^2.1.35",
package/src/response.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const cookie = require("cookie");
2
2
  const mime = require("mime-types");
3
3
  const vary = require("vary");
4
+ const encodeUrl = require("encodeurl");
4
5
  const {
5
6
  normalizeType, stringify, deprecated, UP_PATH_REGEXP, decode,
6
7
  containsDotFile, isPreconditionFailure, isRangeFresh, parseHttpDate
@@ -332,16 +333,18 @@ module.exports = class Response extends Writable {
332
333
  }
333
334
 
334
335
  // if-modified-since
335
- let modifiedSince = this.req.headers['if-modified-since'];
336
- let lastModified = this.headers['last-modified'];
337
- if(options.lastModified && lastModified && modifiedSince) {
338
- modifiedSince = parseHttpDate(modifiedSince);
339
- lastModified = parseHttpDate(lastModified);
340
-
341
- if(!isNaN(lastModified) && !isNaN(modifiedSince) && lastModified <= modifiedSince) {
342
- this.status(304);
343
- return this.end();
344
- };
336
+ if(options.ifModifiedSince) {
337
+ let modifiedSince = this.req.headers['if-modified-since'];
338
+ let lastModified = this.headers['last-modified'];
339
+ if(options.lastModified && lastModified && modifiedSince) {
340
+ modifiedSince = parseHttpDate(modifiedSince);
341
+ lastModified = parseHttpDate(lastModified);
342
+
343
+ if(!isNaN(lastModified) && !isNaN(modifiedSince) && lastModified <= modifiedSince) {
344
+ this.status(304);
345
+ return this.end();
346
+ };
347
+ }
345
348
  }
346
349
 
347
350
  // range requests
@@ -596,7 +599,7 @@ module.exports = class Response extends Writable {
596
599
  if(!path) path = this.req.get('Referer');
597
600
  if(!path) path = '/';
598
601
  }
599
- return this.set('Location', encodeURI(path));
602
+ return this.set('Location', encodeUrl(path));
600
603
  }
601
604
  redirect(status, url) {
602
605
  if(typeof status !== 'number' && !url) {