@orpc/standard-server-fetch 0.0.0-next.68378b4 → 0.0.0-next.6896c4f

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 CHANGED
@@ -32,7 +32,7 @@
32
32
  - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
33
  - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
34
  - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
35
+ - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
36
  - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
37
  - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
38
  - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
@@ -55,14 +55,26 @@ You can find the full documentation [here](https://orpc.unnoq.com).
55
55
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
56
  - [@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
57
  - [@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
+ - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
59
+ - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
58
60
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
61
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
62
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
63
+ - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
64
+ - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
61
65
 
62
66
  ## `@orpc/standard-server-fetch`
63
67
 
64
68
  [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) server adapter for oRPC.
65
69
 
70
+ ## Sponsors
71
+
72
+ <p align="center">
73
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
74
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
75
+ </a>
76
+ </p>
77
+
66
78
  ## License
67
79
 
68
80
  Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
package/dist/index.d.mts CHANGED
@@ -21,7 +21,7 @@ interface ToEventStreamOptions {
21
21
  */
22
22
  eventIteratorKeepAliveComment?: string;
23
23
  }
24
- declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options: ToEventStreamOptions): ReadableStream<Uint8Array>;
24
+ declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): ReadableStream<Uint8Array>;
25
25
 
26
26
  declare function toStandardBody(re: Request | Response): Promise<StandardBody>;
27
27
  interface ToFetchBodyOptions extends ToEventStreamOptions {
@@ -30,7 +30,7 @@ interface ToFetchBodyOptions extends ToEventStreamOptions {
30
30
  * @param body
31
31
  * @param headers - The headers can be changed by the function and effects on the original headers.
32
32
  */
33
- declare function toFetchBody(body: StandardBody, headers: Headers, options: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>;
33
+ declare function toFetchBody(body: StandardBody, headers: Headers, options?: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>;
34
34
 
35
35
  /**
36
36
  * @param headers
@@ -46,11 +46,11 @@ declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers
46
46
  declare function toStandardLazyRequest(request: Request): StandardLazyRequest;
47
47
  interface ToFetchRequestOptions extends ToFetchBodyOptions {
48
48
  }
49
- declare function toFetchRequest(request: StandardRequest, options: ToFetchRequestOptions): Request;
49
+ declare function toFetchRequest(request: StandardRequest, options?: ToFetchRequestOptions): Request;
50
50
 
51
51
  interface ToFetchResponseOptions extends ToFetchBodyOptions {
52
52
  }
53
- declare function toFetchResponse(response: StandardResponse, options: ToFetchResponseOptions): Response;
53
+ declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response;
54
54
  declare function toStandardLazyResponse(response: Response): StandardLazyResponse;
55
55
 
56
56
  export { type ToEventStreamOptions, type ToFetchBodyOptions, type ToFetchRequestOptions, type ToFetchResponseOptions, toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ interface ToEventStreamOptions {
21
21
  */
22
22
  eventIteratorKeepAliveComment?: string;
23
23
  }
24
- declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options: ToEventStreamOptions): ReadableStream<Uint8Array>;
24
+ declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): ReadableStream<Uint8Array>;
25
25
 
26
26
  declare function toStandardBody(re: Request | Response): Promise<StandardBody>;
27
27
  interface ToFetchBodyOptions extends ToEventStreamOptions {
@@ -30,7 +30,7 @@ interface ToFetchBodyOptions extends ToEventStreamOptions {
30
30
  * @param body
31
31
  * @param headers - The headers can be changed by the function and effects on the original headers.
32
32
  */
33
- declare function toFetchBody(body: StandardBody, headers: Headers, options: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>;
33
+ declare function toFetchBody(body: StandardBody, headers: Headers, options?: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>;
34
34
 
35
35
  /**
36
36
  * @param headers
@@ -46,11 +46,11 @@ declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers
46
46
  declare function toStandardLazyRequest(request: Request): StandardLazyRequest;
47
47
  interface ToFetchRequestOptions extends ToFetchBodyOptions {
48
48
  }
49
- declare function toFetchRequest(request: StandardRequest, options: ToFetchRequestOptions): Request;
49
+ declare function toFetchRequest(request: StandardRequest, options?: ToFetchRequestOptions): Request;
50
50
 
51
51
  interface ToFetchResponseOptions extends ToFetchBodyOptions {
52
52
  }
53
- declare function toFetchResponse(response: StandardResponse, options: ToFetchResponseOptions): Response;
53
+ declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response;
54
54
  declare function toStandardLazyResponse(response: Response): StandardLazyResponse;
55
55
 
56
56
  export { type ToEventStreamOptions, type ToFetchBodyOptions, type ToFetchRequestOptions, type ToFetchResponseOptions, toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
package/dist/index.mjs CHANGED
@@ -42,7 +42,7 @@ function toEventIterator(stream) {
42
42
  }
43
43
  return gen();
44
44
  }
45
- function toEventStream(iterator, options) {
45
+ function toEventStream(iterator, options = {}) {
46
46
  const keepAliveEnabled = options.eventIteratorKeepAliveEnabled ?? true;
47
47
  const keepAliveInterval = options.eventIteratorKeepAliveInterval ?? 5e3;
48
48
  const keepAliveComment = options.eventIteratorKeepAliveComment ?? "";
@@ -125,7 +125,7 @@ async function toStandardBody(re) {
125
125
  type: blob.type
126
126
  });
127
127
  }
128
- function toFetchBody(body, headers, options) {
128
+ function toFetchBody(body, headers, options = {}) {
129
129
  headers.delete("content-type");
130
130
  headers.delete("content-disposition");
131
131
  if (body === void 0) {
@@ -182,14 +182,15 @@ function toFetchHeaders(headers, fetchHeaders = new Headers()) {
182
182
  }
183
183
 
184
184
  function toStandardLazyRequest(request) {
185
+ const raw = { adapter: "fetch", request };
185
186
  return {
186
- raw: { request },
187
+ raw,
187
188
  url: new URL(request.url),
188
189
  signal: request.signal,
189
190
  method: request.method,
190
- body: once(() => toStandardBody(request)),
191
+ body: once(() => toStandardBody(raw.request)),
191
192
  get headers() {
192
- const headers = toStandardHeaders(request.headers);
193
+ const headers = toStandardHeaders(raw.request.headers);
193
194
  Object.defineProperty(this, "headers", { value: headers, writable: true });
194
195
  return headers;
195
196
  },
@@ -198,7 +199,7 @@ function toStandardLazyRequest(request) {
198
199
  }
199
200
  };
200
201
  }
201
- function toFetchRequest(request, options) {
202
+ function toFetchRequest(request, options = {}) {
202
203
  const headers = toFetchHeaders(request.headers);
203
204
  const body = toFetchBody(request.body, headers, options);
204
205
  return new Request(request.url, {
@@ -209,18 +210,19 @@ function toFetchRequest(request, options) {
209
210
  });
210
211
  }
211
212
 
212
- function toFetchResponse(response, options) {
213
+ function toFetchResponse(response, options = {}) {
213
214
  const headers = toFetchHeaders(response.headers);
214
215
  const body = toFetchBody(response.body, headers, options);
215
216
  return new Response(body, { headers, status: response.status });
216
217
  }
217
218
  function toStandardLazyResponse(response) {
219
+ const raw = { adapter: "fetch", response };
218
220
  return {
219
- raw: { response },
220
- body: once(() => toStandardBody(response)),
221
+ raw,
222
+ body: once(() => toStandardBody(raw.response)),
221
223
  status: response.status,
222
224
  get headers() {
223
- const headers = toStandardHeaders(response.headers);
225
+ const headers = toStandardHeaders(raw.response.headers);
224
226
  Object.defineProperty(this, "headers", { value: headers, writable: true });
225
227
  return headers;
226
228
  },
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.68378b4",
4
+ "version": "0.0.0-next.6896c4f",
5
5
  "license": "MIT",
6
6
  "homepage": "https://unnoq.com",
7
7
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@orpc/shared": "0.0.0-next.68378b4",
27
- "@orpc/standard-server": "0.0.0-next.68378b4"
26
+ "@orpc/shared": "0.0.0-next.6896c4f",
27
+ "@orpc/standard-server": "0.0.0-next.6896c4f"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@hono/node-server": "^1.13.8"