srvx 0.7.2 → 0.7.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/dist/adapters/node.mjs +14 -5
- package/package.json +4 -4
package/dist/adapters/node.mjs
CHANGED
|
@@ -222,7 +222,7 @@ function _normalizeValue(value) {
|
|
|
222
222
|
return typeof value === "string" ? value : String(value ?? "");
|
|
223
223
|
}
|
|
224
224
|
function validateHeader(name) {
|
|
225
|
-
if (name[0] === ":") throw new TypeError(
|
|
225
|
+
if (name[0] === ":") throw new TypeError(`${JSON.stringify(name)} is an invalid header name.`);
|
|
226
226
|
return name.toLowerCase();
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -577,13 +577,13 @@ const NodeResponse = /* @__PURE__ */ (() => {
|
|
|
577
577
|
const statusText = this.#init?.statusText ?? "";
|
|
578
578
|
const headers = [];
|
|
579
579
|
const headersInit = this.#init?.headers;
|
|
580
|
-
if (
|
|
580
|
+
if (this.#headersObj) for (const [key, value] of this.#headersObj) if (key === "set-cookie") for (const setCookie of splitSetCookieString(value)) headers.push(["set-cookie", setCookie]);
|
|
581
|
+
else headers.push([key, value]);
|
|
582
|
+
else if (headersInit) {
|
|
581
583
|
const headerEntries = Array.isArray(headersInit) ? headersInit : headersInit.entries ? headersInit.entries() : Object.entries(headersInit);
|
|
582
584
|
for (const [key, value] of headerEntries) if (key === "set-cookie") for (const setCookie of splitSetCookieString(value)) headers.push(["set-cookie", setCookie]);
|
|
583
585
|
else headers.push([key, value]);
|
|
584
586
|
}
|
|
585
|
-
if (this.#headersObj) for (const [key, value] of this.#headersObj) if (key === "set-cookie") for (const setCookie of splitSetCookieString(value)) headers.push(["set-cookie", setCookie]);
|
|
586
|
-
else headers.push([key, value]);
|
|
587
587
|
const bodyInit = this.#body;
|
|
588
588
|
let body;
|
|
589
589
|
if (bodyInit) if (typeof bodyInit === "string") body = bodyInit;
|
|
@@ -602,6 +602,8 @@ const NodeResponse = /* @__PURE__ */ (() => {
|
|
|
602
602
|
}
|
|
603
603
|
this.#body = void 0;
|
|
604
604
|
this.#init = void 0;
|
|
605
|
+
this.#headersObj = void 0;
|
|
606
|
+
this.#responseObj = void 0;
|
|
605
607
|
return {
|
|
606
608
|
status,
|
|
607
609
|
statusText,
|
|
@@ -615,11 +617,18 @@ const NodeResponse = /* @__PURE__ */ (() => {
|
|
|
615
617
|
#headersObj;
|
|
616
618
|
clone() {
|
|
617
619
|
if (this.#responseObj) return this.#responseObj.clone();
|
|
620
|
+
if (this.#headersObj) return new globalThis.Response(this.#body, {
|
|
621
|
+
...this.#init,
|
|
622
|
+
headers: new Headers(this.#headersObj)
|
|
623
|
+
});
|
|
618
624
|
return new globalThis.Response(this.#body, this.#init);
|
|
619
625
|
}
|
|
620
626
|
get #response() {
|
|
621
627
|
if (!this.#responseObj) {
|
|
622
|
-
this.#responseObj = new globalThis.Response(this.#body,
|
|
628
|
+
this.#responseObj = this.#headersObj ? new globalThis.Response(this.#body, {
|
|
629
|
+
...this.#init,
|
|
630
|
+
headers: new Headers(this.#headersObj)
|
|
631
|
+
}) : new globalThis.Response(this.#body, this.#init);
|
|
623
632
|
this.#body = void 0;
|
|
624
633
|
this.#init = void 0;
|
|
625
634
|
this.#headersObj = void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srvx",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Universal Server API based on web platform standards. Works seamlessly with Deno, Bun and Node.js.",
|
|
5
5
|
"homepage": "https://srvx.h3.dev",
|
|
6
6
|
"repository": "h3js/srvx",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"lint:fix": "automd && eslint . --fix && prettier -w .",
|
|
41
41
|
"node-ts": "node --disable-warning=ExperimentalWarning --experimental-strip-types",
|
|
42
42
|
"prepack": "pnpm build",
|
|
43
|
-
"play:bun": "bun playground/app.mjs",
|
|
43
|
+
"play:bun": "bun --watch playground/app.mjs",
|
|
44
44
|
"play:cf": "pnpx wrangler dev playground/app.mjs",
|
|
45
|
-
"play:deno": "deno run -A playground/app.mjs",
|
|
45
|
+
"play:deno": "deno run -A --watch playground/app.mjs",
|
|
46
46
|
"play:mkcert": "openssl req -x509 -newkey rsa:2048 -nodes -keyout server.key -out server.crt -days 365 -subj /CN=srvx.local",
|
|
47
|
-
"play:node": "pnpm node-ts playground/app.mjs",
|
|
47
|
+
"play:node": "pnpm node-ts --watch playground/app.mjs",
|
|
48
48
|
"play:sw": "pnpm build && pnpx serve playground",
|
|
49
49
|
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
|
50
50
|
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|