ultimate-express 1.3.16 → 1.3.18

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.16",
3
+ "version": "1.3.18",
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": {
@@ -72,7 +72,8 @@
72
72
  "ejs": "^3.1.10",
73
73
  "errorhandler": "^1.5.1",
74
74
  "exit-hook": "^2.2.1",
75
- "express": "^4.19.2",
75
+ "express-4": "npm:express@4",
76
+ "express-5": "npm:express@5",
76
77
  "express-art-template": "^1.0.1",
77
78
  "express-async-errors": "^3.1.1",
78
79
  "express-dot-engine": "^1.0.8",
@@ -180,11 +180,6 @@ function createBodyParser(defaultType, beforeReturn) {
180
180
  return next();
181
181
  }
182
182
 
183
- // skip reading too large body
184
- if(length && +length > options.limit) {
185
- return next(new Error('Request entity too large'));
186
- }
187
-
188
183
  if(options.simpleType) {
189
184
  const semicolonIndex = type.indexOf(';');
190
185
  const clearType = semicolonIndex !== -1 ? type.substring(0, semicolonIndex) : type;
@@ -203,6 +198,12 @@ function createBodyParser(defaultType, beforeReturn) {
203
198
  }
204
199
  }
205
200
 
201
+ // skip reading too large body
202
+ if(length && +length > options.limit) {
203
+ return next(new Error('Request entity too large'));
204
+ }
205
+
206
+
206
207
  // skip reading body for non-POST requests
207
208
  // this makes it +10k req/sec faster
208
209
  if( additionalMethods === undefined ) additionalMethods = req.app.get('body methods') ?? null;
package/src/request.js CHANGED
@@ -106,7 +106,7 @@ module.exports = class Request extends Readable {
106
106
  }
107
107
  }
108
108
 
109
- async _read() {
109
+ _read() {
110
110
  if(!this.receivedData || !this.bufferedData) {
111
111
  return;
112
112
  }
package/src/response.js CHANGED
@@ -556,7 +556,9 @@ module.exports = class Response extends Writable {
556
556
  get(field) {
557
557
  return this.headers[field.toLowerCase()];
558
558
  }
559
- getHeader = this.get;
559
+ getHeader(field) {
560
+ return this.get(field);
561
+ }
560
562
  removeHeader(field) {
561
563
  delete this.headers[field.toLowerCase()];
562
564
  return this;
@@ -568,7 +570,7 @@ module.exports = class Response extends Writable {
568
570
  const newVal = [];
569
571
  if(Array.isArray(old)) {
570
572
  newVal.push(...old);
571
- } else if(old) {
573
+ } else {
572
574
  newVal.push(old);
573
575
  }
574
576
  if(Array.isArray(value)) {
package/src/router.js CHANGED
@@ -108,6 +108,10 @@ module.exports = class Router extends EventEmitter {
108
108
  let path = req._opPath;
109
109
  let pattern = route.pattern;
110
110
 
111
+ if(req.endsWithSlash && path.endsWith('/') && !this.get('strict routing')) {
112
+ path = path.slice(0, -1);
113
+ }
114
+
111
115
  if (typeof pattern === 'string') {
112
116
  if(pattern === '/*') {
113
117
  return true;
package/src/utils.js CHANGED
@@ -108,7 +108,7 @@ function canBeOptimized(pattern) {
108
108
  function acceptParams(str) {
109
109
  const length = str.length;
110
110
  const colonIndex = str.indexOf(';');
111
- const index = colonIndex === -1 ? length : colonIndex;
111
+ let index = colonIndex === -1 ? length : colonIndex;
112
112
  const ret = { value: str.slice(0, index).trim(), quality: 1, params: {} };
113
113
 
114
114
  while (index < length) {