ultimate-express 1.1.1 → 1.1.3
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/EXPRESS_LICENSE +1 -1
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/response.js +5 -3
package/EXPRESS_LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ This library is a very fast re-implementation of Express.js 4.
|
|
|
6
6
|
It is designed to be a drop-in replacement for Express.js, with the same API and functionality, while being much faster. It is not a fork of Express.js.
|
|
7
7
|
To make sure µExpress matches behavior of Express in all cases, we run all tests with Express first, and then with µExpress and compare results to make sure they match.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`npm install ultimate-express` -> replace `express` with `ultimate-express` -> done[*](https://github.com/dimdenGD/ultimate-express?tab=readme-ov-file#differences-from-express)
|
|
10
10
|
|
|
11
|
-

|
|
11
|
+
[](https://nodejs.org)
|
|
12
12
|
[](https://npmjs.com/package/ultimate-express)
|
|
13
13
|
|
|
14
14
|
## Difference from similar projects
|
|
@@ -93,7 +93,7 @@ Optimized routes can be up to 10 times faster than normal routes, as they're usi
|
|
|
93
93
|
|
|
94
94
|
3. Do not set `body methods` to read body of requests with GET method or other methods that don't need a body. Reading body makes server about 10k req/sec slower.
|
|
95
95
|
|
|
96
|
-
4. By default, µExpress creates 1 (or 0 if your CPU has only 1 core) child thread to improve performance of reading files
|
|
96
|
+
4. By default, µExpress creates 1 (or 0 if your CPU has only 1 core) child thread to improve performance of reading files. You can change this number by setting `threads` to a different number in `express()`, or set to 0 to disable thread pool (`express({ threads: 0 })`). Threads are shared between all express() instances, with largest `threads` number being used. Using more threads will not necessarily improve performance. Sometimes not using threads at all is faster, please [test](https://github.com/wg/wrk/) both options.
|
|
97
97
|
|
|
98
98
|
## Compatibility
|
|
99
99
|
|
package/package.json
CHANGED
package/src/response.js
CHANGED
|
@@ -390,7 +390,7 @@ module.exports = class Response extends Writable {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
// serve smaller files using workers
|
|
393
|
-
if(this.app.workers.length && stat.size <
|
|
393
|
+
if(this.app.workers.length && stat.size < 768 * 1024 && !ranged) {
|
|
394
394
|
this.app.readFileWithWorker(fullpath).then((data) => {
|
|
395
395
|
if(this._res.aborted) {
|
|
396
396
|
return;
|
|
@@ -402,7 +402,9 @@ module.exports = class Response extends Writable {
|
|
|
402
402
|
});
|
|
403
403
|
} else {
|
|
404
404
|
// larger files or range requests are piped over response
|
|
405
|
-
let opts = {
|
|
405
|
+
let opts = {
|
|
406
|
+
highWaterMark: 256 * 1024
|
|
407
|
+
};
|
|
406
408
|
if(ranged) {
|
|
407
409
|
opts.start = offset;
|
|
408
410
|
opts.end = Math.max(offset, offset + len - 1);
|
|
@@ -671,7 +673,7 @@ function pipeStreamOverResponse(res, readStream, totalSize, callback) {
|
|
|
671
673
|
res._res.writeHeader(header, res.headers[header]);
|
|
672
674
|
}
|
|
673
675
|
if(!res.headers['content-type']) {
|
|
674
|
-
res._res.writeHeader('content-type', 'text/html');
|
|
676
|
+
res._res.writeHeader('content-type', 'text/html; charset=utf-8');
|
|
675
677
|
}
|
|
676
678
|
res.headersSent = true;
|
|
677
679
|
}
|