@askrjs/node 0.2.1 → 0.2.2
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/dist/index.js +11 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -707,12 +707,14 @@ async function serve(app, options = {}) {
|
|
|
707
707
|
file = void 0;
|
|
708
708
|
}
|
|
709
709
|
if (!candidate || !file?.isFile()) {
|
|
710
|
+
if (response.destroyed || response.writableEnded) return;
|
|
710
711
|
response.writeHead(404, {
|
|
711
712
|
"content-type": "text/plain; charset=utf-8",
|
|
712
713
|
"x-content-type-options": "nosniff"
|
|
713
714
|
}).end("Not Found");
|
|
714
715
|
return;
|
|
715
716
|
}
|
|
717
|
+
if (response.destroyed || response.writableEnded) return;
|
|
716
718
|
response.writeHead(200, {
|
|
717
719
|
"content-type": mimeTypes[extension] ?? "application/octet-stream",
|
|
718
720
|
"content-length": Number(file.size),
|
|
@@ -720,7 +722,15 @@ async function serve(app, options = {}) {
|
|
|
720
722
|
"x-content-type-options": "nosniff"
|
|
721
723
|
});
|
|
722
724
|
if (method === "HEAD") response.end();
|
|
723
|
-
else
|
|
725
|
+
else {
|
|
726
|
+
const source = createReadStream(candidate);
|
|
727
|
+
const stopSource = () => source.destroy();
|
|
728
|
+
response.once("close", stopSource);
|
|
729
|
+
pipeline(source, response, (error) => {
|
|
730
|
+
response.off("close", stopSource);
|
|
731
|
+
if (error) source.destroy();
|
|
732
|
+
});
|
|
733
|
+
}
|
|
724
734
|
return;
|
|
725
735
|
}
|
|
726
736
|
applicationHandler(request, response);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askrjs/node",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Node http adapter for @askrjs/server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askr",
|
|
@@ -57,18 +57,18 @@
|
|
|
57
57
|
"prepublishOnly": "npm run check"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@askrjs/auth": ">=0.2.
|
|
61
|
-
"@askrjs/server": ">=0.2.
|
|
60
|
+
"@askrjs/auth": ">=0.2.1 <0.3.0",
|
|
61
|
+
"@askrjs/server": ">=0.2.1 <0.3.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
63
63
|
"ws": "^8.21.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@askrjs/schema": ">=0.2.
|
|
67
|
-
"@types/node": "^26.
|
|
68
|
-
"publint": "^0.3.
|
|
66
|
+
"@askrjs/schema": ">=0.2.1 <0.3.0",
|
|
67
|
+
"@types/node": "^26.3.0",
|
|
68
|
+
"publint": "^0.3.24",
|
|
69
69
|
"typescript": "^7.0.2",
|
|
70
|
-
"vite-plus": "^0.
|
|
71
|
-
"vitest": "^4.1.
|
|
70
|
+
"vite-plus": "^0.3.0",
|
|
71
|
+
"vitest": "^4.1.11"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=24.0.0"
|