ultimate-express 1.0.3 → 1.0.5

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
@@ -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 | Express req/sec | µExpress req/sec | Express throughput | µExpress throughput | µExpress speedup |
27
- | --------------------------- | ---------------- | --------------- | ---------------- | ------------------ | ------------------- | ---------------- |
28
- | routing/simple-routes.js | / | 10.90k | 70.10k | 2.04 MB/sec | 11.57 MB/sec | **6.43X** |
29
- | routing/lot-of-routes.js | /999 | 4.66k | 51.58k | 0.85 MB/sec | 8.07 MB/sec | **11.07X** |
30
- | routing/some-middlewares.js | /90 | 10.18k | 66.97k | 1.81 MB/sec | 10.42 MB/sec | **6.58X** |
31
- | middlewares/express-static | /static/index.js | 7.52k | 31.08k | 6.92 MB/sec | 26.48 MB/sec | **4.13X** |
32
- | engines/ejs.js | /test | 5.92k | 14.43k | 2.40 MB/sec | 5.53 MB/sec | **2.44X** |
33
- | middlewares/body-urlencoded | /abc (POST) | 7.90k | 29.90k | 1.64 MB/sec | 5.36 MB/sec | **3.78X** |
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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": {
@@ -6,6 +6,7 @@ function static(root, options) {
6
6
  if(typeof options.index === 'undefined') options.index = 'index.html';
7
7
  if(typeof options.redirect === 'undefined') options.redirect = true;
8
8
  if(typeof options.fallthrough === 'undefined') options.fallthrough = true;
9
+ if(typeof options.dotfiles === 'undefined') options.dotfiles = 'ignore_files';
9
10
  if(options.extensions) {
10
11
  if(typeof options.extensions !== 'string' && !Array.isArray(options.extensions)) {
11
12
  throw new Error('extensions must be a string or an array');
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 Buffer.from(this._res.getRemoteAddressAsText()).toString();
143
+ return this.rawIp;
131
144
  }
132
145
  return proxyaddr(this, trust);
133
146
  }
package/src/response.js CHANGED
@@ -271,6 +271,12 @@ module.exports = class Response extends Writable {
271
271
  case 'deny':
272
272
  this.status(403);
273
273
  return done(new Error('Forbidden'));
274
+ case 'ignore_files':
275
+ if(parts.length > 1 && parts[parts.length - 1].startsWith('.')) {
276
+ this.status(404);
277
+ return done(new Error('Not found'));
278
+ }
279
+ break;
274
280
  case 'ignore':
275
281
  default:
276
282
  this.status(404);