srvx 0.11.9 → 0.11.11
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/adapters/node.mjs +14 -17
- package/dist/cli.mjs +1 -1
- package/package.json +11 -11
package/dist/adapters/node.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as prin
|
|
|
4
4
|
import { n as gracefulShutdownPlugin, r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
5
5
|
import nodeHTTP, { IncomingMessage, ServerResponse } from "node:http";
|
|
6
6
|
import { Duplex, PassThrough, Readable } from "node:stream";
|
|
7
|
+
import { pipeline } from "node:stream/promises";
|
|
7
8
|
import nodeHTTPS from "node:https";
|
|
8
9
|
import nodeHTTP2 from "node:http2";
|
|
9
10
|
//#region src/adapters/_node/send.ts
|
|
@@ -17,10 +18,7 @@ async function sendNodeResponse(nodeRes, webRes) {
|
|
|
17
18
|
writeHead(nodeRes, res.status, res.statusText, res.headers);
|
|
18
19
|
if (res.body) {
|
|
19
20
|
if (res.body instanceof ReadableStream) return streamBody(res.body, nodeRes);
|
|
20
|
-
else if (typeof res.body?.pipe === "function")
|
|
21
|
-
res.body.pipe(nodeRes);
|
|
22
|
-
return new Promise((resolve) => nodeRes.on("close", resolve));
|
|
23
|
-
}
|
|
21
|
+
else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes);
|
|
24
22
|
nodeRes.write(res.body);
|
|
25
23
|
}
|
|
26
24
|
return endNodeResponse(nodeRes);
|
|
@@ -37,6 +35,15 @@ function writeHead(nodeRes, status, statusText, rawHeaders) {
|
|
|
37
35
|
function endNodeResponse(nodeRes) {
|
|
38
36
|
return new Promise((resolve) => nodeRes.end(resolve));
|
|
39
37
|
}
|
|
38
|
+
function pipeBody(stream, nodeRes) {
|
|
39
|
+
if (nodeRes.destroyed) {
|
|
40
|
+
stream.destroy?.();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (typeof stream.on === "function" && typeof stream.destroy === "function") return pipeline(stream, nodeRes).catch(() => {});
|
|
44
|
+
stream.pipe(nodeRes);
|
|
45
|
+
return new Promise((resolve) => nodeRes.on("close", resolve));
|
|
46
|
+
}
|
|
40
47
|
function streamBody(stream, nodeRes) {
|
|
41
48
|
if (nodeRes.destroyed) {
|
|
42
49
|
stream.cancel();
|
|
@@ -80,9 +87,8 @@ var NodeRequestURL = class extends FastURL {
|
|
|
80
87
|
const pathname = qIndex === -1 ? path : path?.slice(0, qIndex) || "/";
|
|
81
88
|
const search = qIndex === -1 ? "" : path?.slice(qIndex) || "";
|
|
82
89
|
let host = req.headers.host || req.headers[":authority"];
|
|
83
|
-
if (host)
|
|
84
|
-
|
|
85
|
-
} else if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
|
|
90
|
+
if (host && !HOST_RE.test(host)) host = "_invalid_";
|
|
91
|
+
else if (!host) if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
|
|
86
92
|
else host = "localhost";
|
|
87
93
|
const protocol = req.socket?.encrypted || req.headers["x-forwarded-proto"] === "https" || req.headers[":scheme"] === "https" ? "https:" : "http:";
|
|
88
94
|
super({
|
|
@@ -144,17 +150,8 @@ const NodeRequestHeaders = /* @__PURE__ */ (() => {
|
|
|
144
150
|
const value = this.#req.headers["set-cookie"];
|
|
145
151
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
146
152
|
}
|
|
147
|
-
*_entries() {
|
|
148
|
-
const rawHeaders = this.#req.rawHeaders;
|
|
149
|
-
const len = rawHeaders.length;
|
|
150
|
-
for (let i = 0; i < len; i += 2) {
|
|
151
|
-
const key = rawHeaders[i];
|
|
152
|
-
if (key.charCodeAt(0) === 58) continue;
|
|
153
|
-
yield [key.toLowerCase(), rawHeaders[i + 1]];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
153
|
entries() {
|
|
157
|
-
return this
|
|
154
|
+
return this._headers.entries();
|
|
158
155
|
}
|
|
159
156
|
[Symbol.iterator]() {
|
|
160
157
|
return this.entries();
|
package/dist/cli.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srvx",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
4
|
"description": "Universal Server.",
|
|
5
5
|
"homepage": "https://srvx.h3.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"vitest": "vitest"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@cloudflare/workers-types": "^4.
|
|
62
|
+
"@cloudflare/workers-types": "^4.20260313.1",
|
|
63
63
|
"@hono/node-server": "^1.19.11",
|
|
64
64
|
"@mitata/counters": "^0.0.8",
|
|
65
65
|
"@mjackson/node-fetch-server": "^0.7.0",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"@types/bun": "^1.3.10",
|
|
68
68
|
"@types/deno": "^2.5.0",
|
|
69
69
|
"@types/express": "^5.0.6",
|
|
70
|
-
"@types/node": "^25.
|
|
70
|
+
"@types/node": "^25.5.0",
|
|
71
71
|
"@types/node-forge": "^1.3.14",
|
|
72
72
|
"@types/serviceworker": "^0.0.193",
|
|
73
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
74
|
-
"@vitest/coverage-v8": "^4.0
|
|
73
|
+
"@typescript/native-preview": "^7.0.0-dev.20260315.1",
|
|
74
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
75
75
|
"@whatwg-node/server": "^0.10.18",
|
|
76
76
|
"automd": "^0.4.3",
|
|
77
77
|
"changelogen": "^0.6.2",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
"mitata": "^1.0.34",
|
|
85
85
|
"node-forge": "^1.3.3",
|
|
86
86
|
"obuild": "^0.4.32",
|
|
87
|
-
"oxfmt": "^0.
|
|
88
|
-
"oxlint": "^1.
|
|
89
|
-
"srvx-release": "npm:srvx@^0.11.
|
|
87
|
+
"oxfmt": "^0.40.0",
|
|
88
|
+
"oxlint": "^1.55.0",
|
|
89
|
+
"srvx-release": "npm:srvx@^0.11.9",
|
|
90
90
|
"tslib": "^2.8.1",
|
|
91
91
|
"typescript": "^5.9.3",
|
|
92
|
-
"undici": "^7.
|
|
93
|
-
"vitest": "^4.0
|
|
92
|
+
"undici": "^7.24.3",
|
|
93
|
+
"vitest": "^4.1.0"
|
|
94
94
|
},
|
|
95
95
|
"resolutions": {
|
|
96
96
|
"srvx": "link:."
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": ">=20.16.0"
|
|
100
100
|
},
|
|
101
|
-
"packageManager": "pnpm@10.
|
|
101
|
+
"packageManager": "pnpm@10.32.1"
|
|
102
102
|
}
|