@orpc/server 0.36.0 → 0.36.1
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/{chunk-LBBHJSG5.js → chunk-GQ4376GR.js} +6 -6
- package/dist/fetch.js +1 -1
- package/dist/hono.js +2 -2
- package/dist/next.js +1 -1
- package/dist/node.js +5 -5
- package/package.json +4 -4
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
|
7
7
|
// src/adapters/fetch/utils.ts
|
8
8
|
import { once } from "@orpc/shared";
|
9
|
-
import
|
9
|
+
import { contentDisposition, parse as parseContentDisposition } from "@tinyhttp/content-disposition";
|
10
10
|
function fetchHeadersToStandardHeaders(headers) {
|
11
11
|
const standardHeaders = {};
|
12
12
|
for (const [key, value] of headers) {
|
@@ -24,9 +24,9 @@ async function fetchReToStandardBody(re) {
|
|
24
24
|
if (!re.body) {
|
25
25
|
return void 0;
|
26
26
|
}
|
27
|
-
const
|
28
|
-
const fileName =
|
29
|
-
if (fileName) {
|
27
|
+
const contentDisposition2 = re.headers.get("content-disposition");
|
28
|
+
const fileName = contentDisposition2 ? parseContentDisposition(contentDisposition2).parameters.filename : void 0;
|
29
|
+
if (typeof fileName === "string") {
|
30
30
|
const blob2 = await re.blob();
|
31
31
|
return new File([blob2], fileName, {
|
32
32
|
type: blob2.type
|
@@ -86,7 +86,7 @@ function standardResponseToFetchHeaders(response) {
|
|
86
86
|
}
|
87
87
|
}
|
88
88
|
if (response.body instanceof Blob && !fetchHeaders.has("content-disposition")) {
|
89
|
-
fetchHeaders.set("content-disposition",
|
89
|
+
fetchHeaders.set("content-disposition", contentDisposition(response.body instanceof File ? response.body.name : "blob"));
|
90
90
|
} else if (!(response.body instanceof Blob) && !(response.body instanceof URLSearchParams) && !(response.body instanceof FormData) && response.body !== void 0 && !fetchHeaders.has("content-type")) {
|
91
91
|
fetchHeaders.set("content-type", "application/json");
|
92
92
|
}
|
@@ -133,4 +133,4 @@ export {
|
|
133
133
|
standardResponseToFetchResponse,
|
134
134
|
RPCHandler
|
135
135
|
};
|
136
|
-
//# sourceMappingURL=chunk-
|
136
|
+
//# sourceMappingURL=chunk-GQ4376GR.js.map
|
package/dist/fetch.js
CHANGED
package/dist/hono.js
CHANGED
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
fetchRequestToStandardRequest,
|
5
5
|
standardBodyToFetchBody,
|
6
6
|
standardResponseToFetchResponse
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-GQ4376GR.js";
|
8
8
|
import "./chunk-F75AQ6KO.js";
|
9
9
|
import "./chunk-SV6DBVXJ.js";
|
10
10
|
import "./chunk-XFBAK67J.js";
|
@@ -26,7 +26,7 @@ function createMiddleware(handler, ...[options]) {
|
|
26
26
|
const context = await value(options?.context ?? {}, c);
|
27
27
|
const { matched, response } = await handler.handle(request, { ...options, context });
|
28
28
|
if (matched) {
|
29
|
-
return c.
|
29
|
+
return c.newResponse(response.body, response);
|
30
30
|
}
|
31
31
|
await next();
|
32
32
|
};
|
package/dist/next.js
CHANGED
package/dist/node.js
CHANGED
@@ -10,7 +10,7 @@ import "./chunk-XFBAK67J.js";
|
|
10
10
|
import { Buffer, File } from "node:buffer";
|
11
11
|
import { Readable } from "node:stream";
|
12
12
|
import { once } from "@orpc/shared";
|
13
|
-
import
|
13
|
+
import { contentDisposition, parse as parseContentDisposition } from "@tinyhttp/content-disposition";
|
14
14
|
function nodeHttpToStandardRequest(req, res) {
|
15
15
|
const method = req.method ?? "GET";
|
16
16
|
const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
@@ -50,7 +50,7 @@ function nodeHttpResponseSendStandardResponse(res, standardResponse) {
|
|
50
50
|
"content-length": standardResponse.body.size.toString()
|
51
51
|
};
|
52
52
|
if (!standardResponse.headers["content-disposition"] && standardResponse.body instanceof Blob) {
|
53
|
-
resHeaders["content-disposition"] =
|
53
|
+
resHeaders["content-disposition"] = contentDisposition(standardResponse.body instanceof File ? standardResponse.body.name : "blob");
|
54
54
|
}
|
55
55
|
res.writeHead(standardResponse.status, resHeaders);
|
56
56
|
Readable.fromWeb(
|
@@ -93,10 +93,10 @@ async function nodeHttpRequestToStandardBody(req) {
|
|
93
93
|
if (method === "GET" || method === "HEAD") {
|
94
94
|
return void 0;
|
95
95
|
}
|
96
|
-
const
|
97
|
-
const fileName =
|
96
|
+
const contentDisposition2 = req.headers["content-disposition"];
|
97
|
+
const fileName = contentDisposition2 ? parseContentDisposition(contentDisposition2).parameters.filename : void 0;
|
98
98
|
const contentType = req.headers["content-type"];
|
99
|
-
if (fileName) {
|
99
|
+
if (typeof fileName === "string") {
|
100
100
|
return await streamToFile(req, fileName, contentType || "application/octet-stream");
|
101
101
|
}
|
102
102
|
if (!contentType || contentType.startsWith("application/json")) {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.36.
|
4
|
+
"version": "0.36.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -63,9 +63,9 @@
|
|
63
63
|
"next": ">=14.0.0"
|
64
64
|
},
|
65
65
|
"dependencies": {
|
66
|
-
"content-disposition": "^
|
67
|
-
"@orpc/contract": "0.36.
|
68
|
-
"@orpc/shared": "0.36.
|
66
|
+
"@tinyhttp/content-disposition": "^2.2.2",
|
67
|
+
"@orpc/contract": "0.36.1",
|
68
|
+
"@orpc/shared": "0.36.1"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
71
|
"light-my-request": "^6.5.1"
|