ultimate-express 1.3.14 → 1.3.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-express",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
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": {
@@ -42,10 +42,10 @@
42
42
  "dependencies": {
43
43
  "@types/express": "^4.0.0",
44
44
  "accepts": "^1.3.8",
45
- "acorn": "^8.12.1",
45
+ "acorn": "^8.14.0",
46
46
  "bytes": "^3.1.2",
47
- "cookie": "^1.0.1",
48
- "cookie-signature": "^1.2.1",
47
+ "cookie": "^1.0.2",
48
+ "cookie-signature": "^1.2.2",
49
49
  "encodeurl": "^2.0.0",
50
50
  "etag": "^1.8.1",
51
51
  "fast-querystring": "^1.1.2",
@@ -54,18 +54,18 @@
54
54
  "mime-types": "^2.1.35",
55
55
  "ms": "^2.1.3",
56
56
  "proxy-addr": "^2.0.7",
57
- "qs": "^6.13.0",
57
+ "qs": "^6.13.1",
58
58
  "range-parser": "^1.2.1",
59
59
  "statuses": "^2.0.1",
60
- "tseep": "^1.2.2",
60
+ "tseep": "^1.3.1",
61
61
  "type-is": "^1.6.18",
62
- "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.49.0",
62
+ "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.51.0",
63
63
  "vary": "^1.1.2"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@codechecks/client": "^0.1.12",
67
67
  "body-parser": "^1.20.3",
68
- "compression": "^1.7.4",
68
+ "compression": "^1.7.5",
69
69
  "cookie-parser": "^1.4.6",
70
70
  "cookie-session": "^2.1.0",
71
71
  "cors": "^2.8.5",
@@ -78,7 +78,7 @@
78
78
  "express-dot-engine": "^1.0.8",
79
79
  "express-fileupload": "^1.5.1",
80
80
  "express-handlebars": "^8.0.1",
81
- "express-rate-limit": "^7.4.0",
81
+ "express-rate-limit": "^7.4.1",
82
82
  "express-session": "^1.18.0",
83
83
  "express-subdomain": "^1.0.6",
84
84
  "formdata-node": "^6.0.3",
@@ -88,7 +88,7 @@
88
88
  "pako": "^2.1.0",
89
89
  "pkg-pr-new": "^0.0.29",
90
90
  "pug": "^3.0.3",
91
- "response-time": "^2.3.2",
91
+ "response-time": "^2.3.3",
92
92
  "serve-index": "^1.9.1",
93
93
  "serve-static": "^1.16.2",
94
94
  "swig": "^1.4.2",
@@ -156,14 +156,17 @@ function createBodyParser(defaultType, beforeReturn) {
156
156
  }
157
157
  if(typeof options.defaultCharset === 'undefined') options.defaultCharset = 'utf-8';
158
158
 
159
- return (req, res, next) => {
160
- const type = req.headers['content-type'];
159
+ let additionalMethods;
161
160
 
161
+ return (req, res, next) => {
162
+
162
163
  // skip reading body twice
163
164
  if(req.bodyRead) {
164
165
  return next();
165
166
  }
166
167
 
168
+ const type = req.headers['content-type'];
169
+
167
170
  req.body = new NullObject();
168
171
 
169
172
  // skip reading body for non-json content type
@@ -202,7 +205,7 @@ function createBodyParser(defaultType, beforeReturn) {
202
205
 
203
206
  // skip reading body for non-POST requests
204
207
  // this makes it +10k req/sec faster
205
- const additionalMethods = req.app.get('body methods');
208
+ if( additionalMethods === undefined ) additionalMethods = req.app.get('body methods') ?? null;
206
209
  if(
207
210
  req.method !== 'POST' &&
208
211
  req.method !== 'PUT' &&
package/src/response.js CHANGED
@@ -601,26 +601,24 @@ module.exports = class Response extends Writable {
601
601
  this.app.render(view, options, done);
602
602
  }
603
603
  cookie(name, value, options) {
604
- if(!options) {
605
- options = {};
606
- }
604
+ const opt = {...(options ?? {})}; // create a new ref because we change original object (https://github.com/dimdenGD/ultimate-express/issues/68)
607
605
  let val = typeof value === 'object' ? "j:"+JSON.stringify(value) : String(value);
608
- if(options.maxAge != null) {
609
- const maxAge = options.maxAge - 0;
606
+ if(opt.maxAge != null) {
607
+ const maxAge = opt.maxAge - 0;
610
608
  if(!isNaN(maxAge)) {
611
- options.expires = new Date(Date.now() + maxAge);
612
- options.maxAge = Math.floor(maxAge / 1000);
609
+ opt.expires = new Date(Date.now() + maxAge);
610
+ opt.maxAge = Math.floor(maxAge / 1000);
613
611
  }
614
612
  }
615
- if(options.signed) {
613
+ if(opt.signed) {
616
614
  val = 's:' + sign(val, this.req.secret);
617
615
  }
618
616
 
619
- if(options.path == null) {
620
- options.path = '/';
617
+ if(opt.path == null) {
618
+ opt.path = '/';
621
619
  }
622
620
 
623
- this.append('Set-Cookie', cookie.serialize(name, val, options));
621
+ this.append('Set-Cookie', cookie.serialize(name, val, opt));
624
622
  return this;
625
623
  }
626
624
  clearCookie(name, options) {