@orpc/standard-server-node 0.52.0 → 0.54.0
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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +16 -17
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -53,4 +53,5 @@ declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: S
|
|
|
53
53
|
|
|
54
54
|
declare function toAbortSignal(res: NodeHttpResponse): AbortSignal;
|
|
55
55
|
|
|
56
|
-
export {
|
|
56
|
+
export { sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
|
|
57
|
+
export type { NodeHttpRequest, NodeHttpResponse, SendStandardResponseOptions, ToEventStreamOptions, ToNodeHttpBodyOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -53,4 +53,5 @@ declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: S
|
|
|
53
53
|
|
|
54
54
|
declare function toAbortSignal(res: NodeHttpResponse): AbortSignal;
|
|
55
55
|
|
|
56
|
-
export {
|
|
56
|
+
export { sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
|
|
57
|
+
export type { NodeHttpRequest, NodeHttpResponse, SendStandardResponseOptions, ToEventStreamOptions, ToNodeHttpBodyOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
-
import { stringifyJSON, parseEmptyableJSON, isTypescriptObject, isAsyncIteratorObject, once } from '@orpc/shared';
|
|
3
|
-
import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta,
|
|
2
|
+
import { stringifyJSON, parseEmptyableJSON, isTypescriptObject, toArray, isAsyncIteratorObject, once } from '@orpc/shared';
|
|
3
|
+
import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@orpc/standard-server';
|
|
4
4
|
|
|
5
5
|
function toEventIterator(stream) {
|
|
6
6
|
const eventStream = Readable.toWeb(stream).pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
@@ -60,11 +60,14 @@ function toEventStream(iterator, options = {}) {
|
|
|
60
60
|
}
|
|
61
61
|
const value = await iterator.next();
|
|
62
62
|
clearInterval(timeout);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
const meta = getEventMeta(value.value);
|
|
64
|
+
if (!value.done || value.value !== void 0 || meta !== void 0) {
|
|
65
|
+
controller.enqueue(encodeEventMessage({
|
|
66
|
+
...meta,
|
|
67
|
+
event: value.done ? "done" : "message",
|
|
68
|
+
data: stringifyJSON(value.value)
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
68
71
|
if (value.done) {
|
|
69
72
|
controller.close();
|
|
70
73
|
}
|
|
@@ -94,13 +97,11 @@ async function toStandardBody(req) {
|
|
|
94
97
|
if (method === "GET" || method === "HEAD") {
|
|
95
98
|
return void 0;
|
|
96
99
|
}
|
|
97
|
-
const
|
|
100
|
+
const contentDisposition = req.headers["content-disposition"];
|
|
98
101
|
const contentType = req.headers["content-type"];
|
|
99
|
-
if (
|
|
100
|
-
const fileName =
|
|
101
|
-
|
|
102
|
-
return _streamToFile(req, fileName, contentType ?? "");
|
|
103
|
-
}
|
|
102
|
+
if (typeof contentDisposition === "string") {
|
|
103
|
+
const fileName = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
|
104
|
+
return _streamToFile(req, fileName, contentType ?? "");
|
|
104
105
|
}
|
|
105
106
|
if (!contentType || contentType.startsWith("application/json")) {
|
|
106
107
|
const text = await _streamToString(req);
|
|
@@ -122,6 +123,7 @@ async function toStandardBody(req) {
|
|
|
122
123
|
return _streamToFile(req, "blob", contentType);
|
|
123
124
|
}
|
|
124
125
|
function toNodeHttpBody(body, headers, options = {}) {
|
|
126
|
+
const currentContentDisposition = toArray(headers["content-disposition"])[0];
|
|
125
127
|
delete headers["content-type"];
|
|
126
128
|
delete headers["content-disposition"];
|
|
127
129
|
if (body === void 0) {
|
|
@@ -130,10 +132,7 @@ function toNodeHttpBody(body, headers, options = {}) {
|
|
|
130
132
|
if (body instanceof Blob) {
|
|
131
133
|
headers["content-type"] = body.type;
|
|
132
134
|
headers["content-length"] = body.size.toString();
|
|
133
|
-
headers["content-disposition"] =
|
|
134
|
-
body instanceof File ? body.name : "blob",
|
|
135
|
-
{ type: "inline" }
|
|
136
|
-
);
|
|
135
|
+
headers["content-disposition"] = currentContentDisposition ?? generateContentDisposition(body instanceof File ? body.name : "blob");
|
|
137
136
|
return Readable.fromWeb(body.stream());
|
|
138
137
|
}
|
|
139
138
|
if (body instanceof FormData) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.54.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@orpc/
|
|
27
|
-
"@orpc/
|
|
26
|
+
"@orpc/standard-server": "0.54.0",
|
|
27
|
+
"@orpc/shared": "0.54.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/node": "^22.
|
|
31
|
-
"@types/supertest": "^6.0.
|
|
32
|
-
"supertest": "^7.
|
|
30
|
+
"@types/node": "^22.14.0",
|
|
31
|
+
"@types/supertest": "^6.0.3",
|
|
32
|
+
"supertest": "^7.1.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "unbuild",
|