@orpc/standard-server-fetch 0.0.0-next.f4d410a → 0.0.0-next.f81b4a2
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/README.md +11 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +18 -18
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
57
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
|
57
58
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
58
59
|
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
@@ -60,11 +61,21 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
60
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
61
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
62
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
63
66
|
|
|
64
67
|
## `@orpc/standard-server-fetch`
|
|
65
68
|
|
|
66
69
|
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) server adapter for oRPC.
|
|
67
70
|
|
|
71
|
+
## Sponsors
|
|
72
|
+
|
|
73
|
+
<p align="center">
|
|
74
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
|
75
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
|
76
|
+
</a>
|
|
77
|
+
</p>
|
|
78
|
+
|
|
68
79
|
## License
|
|
69
80
|
|
|
70
81
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -53,4 +53,5 @@ interface ToFetchResponseOptions extends ToFetchBodyOptions {
|
|
|
53
53
|
declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response;
|
|
54
54
|
declare function toStandardLazyResponse(response: Response): StandardLazyResponse;
|
|
55
55
|
|
|
56
|
-
export {
|
|
56
|
+
export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
|
|
57
|
+
export type { ToEventStreamOptions, ToFetchBodyOptions, ToFetchRequestOptions, ToFetchResponseOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -53,4 +53,5 @@ interface ToFetchResponseOptions extends ToFetchBodyOptions {
|
|
|
53
53
|
declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response;
|
|
54
54
|
declare function toStandardLazyResponse(response: Response): StandardLazyResponse;
|
|
55
55
|
|
|
56
|
-
export {
|
|
56
|
+
export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
|
|
57
|
+
export type { ToEventStreamOptions, ToFetchBodyOptions, ToFetchRequestOptions, ToFetchResponseOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stringifyJSON, parseEmptyableJSON, isTypescriptObject, isAsyncIteratorObject, once } from '@orpc/shared';
|
|
2
|
-
import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta,
|
|
2
|
+
import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@orpc/standard-server';
|
|
3
3
|
|
|
4
4
|
function toEventIterator(stream) {
|
|
5
5
|
const eventStream = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
@@ -59,11 +59,14 @@ function toEventStream(iterator, options = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
const value = await iterator.next();
|
|
61
61
|
clearInterval(timeout);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
const meta = getEventMeta(value.value);
|
|
63
|
+
if (!value.done || value.value !== void 0 || meta !== void 0) {
|
|
64
|
+
controller.enqueue(encodeEventMessage({
|
|
65
|
+
...meta,
|
|
66
|
+
event: value.done ? "done" : "message",
|
|
67
|
+
data: stringifyJSON(value.value)
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
67
70
|
if (value.done) {
|
|
68
71
|
controller.close();
|
|
69
72
|
}
|
|
@@ -92,15 +95,13 @@ async function toStandardBody(re) {
|
|
|
92
95
|
if (!re.body) {
|
|
93
96
|
return void 0;
|
|
94
97
|
}
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const fileName =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
}
|
|
98
|
+
const contentDisposition = re.headers.get("content-disposition");
|
|
99
|
+
if (typeof contentDisposition === "string") {
|
|
100
|
+
const fileName = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
|
101
|
+
const blob2 = await re.blob();
|
|
102
|
+
return new File([blob2], fileName, {
|
|
103
|
+
type: blob2.type
|
|
104
|
+
});
|
|
104
105
|
}
|
|
105
106
|
const contentType = re.headers.get("content-type");
|
|
106
107
|
if (!contentType || contentType.startsWith("application/json")) {
|
|
@@ -126,6 +127,7 @@ async function toStandardBody(re) {
|
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
function toFetchBody(body, headers, options = {}) {
|
|
130
|
+
const currentContentDisposition = headers.get("content-disposition");
|
|
129
131
|
headers.delete("content-type");
|
|
130
132
|
headers.delete("content-disposition");
|
|
131
133
|
if (body === void 0) {
|
|
@@ -136,7 +138,7 @@ function toFetchBody(body, headers, options = {}) {
|
|
|
136
138
|
headers.set("content-length", body.size.toString());
|
|
137
139
|
headers.set(
|
|
138
140
|
"content-disposition",
|
|
139
|
-
|
|
141
|
+
currentContentDisposition ?? generateContentDisposition(body instanceof File ? body.name : "blob")
|
|
140
142
|
);
|
|
141
143
|
return body;
|
|
142
144
|
}
|
|
@@ -183,7 +185,6 @@ function toFetchHeaders(headers, fetchHeaders = new Headers()) {
|
|
|
183
185
|
|
|
184
186
|
function toStandardLazyRequest(request) {
|
|
185
187
|
return {
|
|
186
|
-
raw: { request },
|
|
187
188
|
url: new URL(request.url),
|
|
188
189
|
signal: request.signal,
|
|
189
190
|
method: request.method,
|
|
@@ -216,7 +217,6 @@ function toFetchResponse(response, options = {}) {
|
|
|
216
217
|
}
|
|
217
218
|
function toStandardLazyResponse(response) {
|
|
218
219
|
return {
|
|
219
|
-
raw: { response },
|
|
220
220
|
body: once(() => toStandardBody(response)),
|
|
221
221
|
status: response.status,
|
|
222
222
|
get headers() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.f81b4a2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@orpc/
|
|
27
|
-
"@orpc/
|
|
26
|
+
"@orpc/shared": "0.0.0-next.f81b4a2",
|
|
27
|
+
"@orpc/standard-server": "0.0.0-next.f81b4a2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@hono/node-server": "^1.
|
|
30
|
+
"@hono/node-server": "^1.14.1"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "unbuild",
|