@orpc/standard-server-node 0.0.0-next.df024bb → 0.0.0-next.e0f01a5

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.
@@ -53,16 +53,29 @@ 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).
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
+ - [@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
61
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
62
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
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/).
61
66
 
62
67
  ## `@orpc/standard-server-node`
63
68
 
64
69
  [Node.js](https://nodejs.org) server adapter for oRPC.
65
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
+
66
79
  ## License
67
80
 
68
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
@@ -24,7 +24,7 @@ interface ToEventStreamOptions {
24
24
  */
25
25
  eventIteratorKeepAliveComment?: string;
26
26
  }
27
- declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options: ToEventStreamOptions): Readable;
27
+ declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): Readable;
28
28
 
29
29
  type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
30
30
  /**
@@ -43,14 +43,15 @@ interface ToNodeHttpBodyOptions extends ToEventStreamOptions {
43
43
  * @param headers - WARNING: The headers can be changed by the function and effects on the original headers.
44
44
  * @param options
45
45
  */
46
- declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options: ToNodeHttpBodyOptions): Readable | undefined | string;
46
+ declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options?: ToNodeHttpBodyOptions): Readable | undefined | string;
47
47
 
48
48
  declare function toStandardLazyRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardLazyRequest;
49
49
 
50
50
  interface SendStandardResponseOptions extends ToNodeHttpBodyOptions {
51
51
  }
52
- declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options: SendStandardResponseOptions): Promise<void>;
52
+ declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options?: SendStandardResponseOptions): Promise<void>;
53
53
 
54
54
  declare function toAbortSignal(res: NodeHttpResponse): AbortSignal;
55
55
 
56
- export { type NodeHttpRequest, type NodeHttpResponse, type SendStandardResponseOptions, type ToEventStreamOptions, type ToNodeHttpBodyOptions, sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
56
+ export { sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
57
+ export type { NodeHttpRequest, NodeHttpResponse, SendStandardResponseOptions, ToEventStreamOptions, ToNodeHttpBodyOptions };
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ interface ToEventStreamOptions {
24
24
  */
25
25
  eventIteratorKeepAliveComment?: string;
26
26
  }
27
- declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options: ToEventStreamOptions): Readable;
27
+ declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): Readable;
28
28
 
29
29
  type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
30
30
  /**
@@ -43,14 +43,15 @@ interface ToNodeHttpBodyOptions extends ToEventStreamOptions {
43
43
  * @param headers - WARNING: The headers can be changed by the function and effects on the original headers.
44
44
  * @param options
45
45
  */
46
- declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options: ToNodeHttpBodyOptions): Readable | undefined | string;
46
+ declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options?: ToNodeHttpBodyOptions): Readable | undefined | string;
47
47
 
48
48
  declare function toStandardLazyRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardLazyRequest;
49
49
 
50
50
  interface SendStandardResponseOptions extends ToNodeHttpBodyOptions {
51
51
  }
52
- declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options: SendStandardResponseOptions): Promise<void>;
52
+ declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options?: SendStandardResponseOptions): Promise<void>;
53
53
 
54
54
  declare function toAbortSignal(res: NodeHttpResponse): AbortSignal;
55
55
 
56
- export { type NodeHttpRequest, type NodeHttpResponse, type SendStandardResponseOptions, type ToEventStreamOptions, type ToNodeHttpBodyOptions, sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
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, parseContentDisposition, contentDisposition } from '@orpc/standard-server';
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());
@@ -43,7 +43,7 @@ function toEventIterator(stream) {
43
43
  }
44
44
  return gen();
45
45
  }
46
- function toEventStream(iterator, options) {
46
+ function toEventStream(iterator, options = {}) {
47
47
  const keepAliveEnabled = options.eventIteratorKeepAliveEnabled ?? true;
48
48
  const keepAliveInterval = options.eventIteratorKeepAliveInterval ?? 5e3;
49
49
  const keepAliveComment = options.eventIteratorKeepAliveComment ?? "";
@@ -60,11 +60,14 @@ function toEventStream(iterator, options) {
60
60
  }
61
61
  const value = await iterator.next();
62
62
  clearInterval(timeout);
63
- controller.enqueue(encodeEventMessage({
64
- ...getEventMeta(value.value),
65
- event: value.done ? "done" : "message",
66
- data: stringifyJSON(value.value)
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 contentDisposition2 = req.headers["content-disposition"];
100
+ const contentDisposition = req.headers["content-disposition"];
98
101
  const contentType = req.headers["content-type"];
99
- if (contentDisposition2) {
100
- const fileName = parseContentDisposition(contentDisposition2).parameters.filename;
101
- if (typeof fileName === "string") {
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);
@@ -121,7 +122,8 @@ async function toStandardBody(req) {
121
122
  }
122
123
  return _streamToFile(req, "blob", contentType);
123
124
  }
124
- function toNodeHttpBody(body, headers, options) {
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"] = contentDisposition(
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) {
@@ -197,7 +196,6 @@ function toStandardLazyRequest(req, res) {
197
196
  const host = req.headers.host ?? "localhost";
198
197
  const url = new URL(req.originalUrl ?? req.url ?? "/", `${protocol}//${host}`);
199
198
  return {
200
- raw: { request: req, response: res },
201
199
  method,
202
200
  url,
203
201
  headers: req.headers,
@@ -206,7 +204,7 @@ function toStandardLazyRequest(req, res) {
206
204
  };
207
205
  }
208
206
 
209
- function sendStandardResponse(res, standardResponse, options) {
207
+ function sendStandardResponse(res, standardResponse, options = {}) {
210
208
  return new Promise((resolve, reject) => {
211
209
  res.on("error", reject);
212
210
  res.on("finish", resolve);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/standard-server-node",
3
3
  "type": "module",
4
- "version": "0.0.0-next.df024bb",
4
+ "version": "0.0.0-next.e0f01a5",
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/standard-server": "0.0.0-next.df024bb",
27
- "@orpc/shared": "0.0.0-next.df024bb"
26
+ "@orpc/shared": "0.0.0-next.e0f01a5",
27
+ "@orpc/standard-server": "0.0.0-next.e0f01a5"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/node": "^22.13.1",
31
- "@types/supertest": "^6.0.2",
32
- "supertest": "^7.0.0"
30
+ "@types/node": "^22.14.1",
31
+ "@types/supertest": "^6.0.3",
32
+ "supertest": "^7.1.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "unbuild",