@orpc/standard-server-node 0.0.0-next.b2e67f7 → 0.0.0-next.fea68c1

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 ADDED
@@ -0,0 +1,68 @@
1
+ <div align="center">
2
+ <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 />
3
+ </div>
4
+
5
+ <h1></h1>
6
+
7
+ <div align="center">
8
+ <a href="https://codecov.io/gh/unnoq/orpc">
9
+ <img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@orpc/standard-server-node">
12
+ <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fstandard-server-node?logo=npm" />
13
+ </a>
14
+ <a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
15
+ <img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
16
+ </a>
17
+ <a href="https://discord.gg/TXEbwRBvQn">
18
+ <img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
19
+ </a>
20
+ </div>
21
+
22
+ <h3 align="center">Typesafe APIs Made Simple 🪄</h3>
23
+
24
+ **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
25
+
26
+ ---
27
+
28
+ ## Highlights
29
+
30
+ - **End-to-End Type Safety 🔒**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
31
+ - **First-Class OpenAPI 📄**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
32
+ - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
+ - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
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.
36
+ - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
+ - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
+ - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
39
+ - **Native Types 📦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
40
+ - **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
41
+ - **SSE & Streaming 📡**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
42
+ - **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
43
+ - **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
44
+ - **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
45
+ - **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
46
+
47
+ ## Documentation
48
+
49
+ You can find the full documentation [here](https://orpc.unnoq.com).
50
+
51
+ ## Packages
52
+
53
+ - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
54
+ - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
55
+ - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
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
+ - [@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/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
+ - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
61
+
62
+ ## `@orpc/standard-server-node`
63
+
64
+ [Node.js](https://nodejs.org) server adapter for oRPC.
65
+
66
+ ## License
67
+
68
+ Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  // src/body.ts
2
2
  import { Readable as Readable2 } from "node:stream";
3
- import { contentDisposition, isAsyncIteratorObject, parseContentDisposition, parseEmptyableJSON as parseEmptyableJSON2 } from "@orpc/standard-server";
3
+ import { isAsyncIteratorObject, parseEmptyableJSON as parseEmptyableJSON2, stringifyJSON as stringifyJSON2 } from "@orpc/shared";
4
+ import { contentDisposition, parseContentDisposition } from "@orpc/standard-server";
4
5
 
5
6
  // src/event-source.ts
6
7
  import { Readable } from "node:stream";
8
+ import { isTypescriptObject, parseEmptyableJSON, stringifyJSON } from "@orpc/shared";
7
9
  import {
8
10
  encodeEventMessage,
9
11
  ErrorEvent,
10
12
  EventDecoderStream,
11
13
  getEventMeta,
12
- isEventMetaContainer,
13
- parseEmptyableJSON,
14
14
  UnknownEvent,
15
15
  withEventMeta
16
16
  } from "@orpc/standard-server";
@@ -27,7 +27,7 @@ function toEventIterator(stream) {
27
27
  switch (value.event) {
28
28
  case "message": {
29
29
  let message = parseEmptyableJSON(value.data);
30
- if (isEventMetaContainer(message)) {
30
+ if (isTypescriptObject(message)) {
31
31
  message = withEventMeta(message, value);
32
32
  }
33
33
  yield message;
@@ -42,7 +42,7 @@ function toEventIterator(stream) {
42
42
  }
43
43
  case "done": {
44
44
  let done2 = parseEmptyableJSON(value.data);
45
- if (isEventMetaContainer(done2)) {
45
+ if (isTypescriptObject(done2)) {
46
46
  done2 = withEventMeta(done2, value);
47
47
  }
48
48
  return done2;
@@ -71,7 +71,7 @@ function toEventStream(iterator) {
71
71
  controller.enqueue(encodeEventMessage({
72
72
  ...getEventMeta(value.value),
73
73
  event: value.done ? "done" : "message",
74
- data: JSON.stringify(value.value)
74
+ data: stringifyJSON(value.value)
75
75
  }));
76
76
  if (value.done) {
77
77
  controller.close();
@@ -80,7 +80,7 @@ function toEventStream(iterator) {
80
80
  controller.enqueue(encodeEventMessage({
81
81
  ...getEventMeta(err),
82
82
  event: "error",
83
- data: err instanceof ErrorEvent ? JSON.stringify(err.data) : void 0
83
+ data: err instanceof ErrorEvent ? stringifyJSON(err.data) : void 0
84
84
  }));
85
85
  controller.close();
86
86
  }
@@ -124,7 +124,7 @@ async function toStandardBody(req) {
124
124
  if (contentType.startsWith("text/event-stream")) {
125
125
  return toEventIterator(req);
126
126
  }
127
- if (contentType.startsWith("text/")) {
127
+ if (contentType.startsWith("text/plain")) {
128
128
  return _streamToString(req);
129
129
  }
130
130
  return _streamToFile(req, "blob", contentType);
@@ -160,7 +160,7 @@ function toNodeHttpBody(body, headers) {
160
160
  return toEventStream(body);
161
161
  }
162
162
  headers["content-type"] = "application/json";
163
- return JSON.stringify(body);
163
+ return stringifyJSON2(body);
164
164
  }
165
165
  function _streamToFormData(stream, contentType) {
166
166
  const response = new Response(stream, {
@@ -186,7 +186,7 @@ async function _streamToFile(stream, fileName, contentType) {
186
186
  }
187
187
 
188
188
  // src/request.ts
189
- import { once } from "@orpc/standard-server";
189
+ import { once } from "@orpc/shared";
190
190
 
191
191
  // src/signal.ts
192
192
  function toAbortSignal(res) {
@@ -1,5 +1,4 @@
1
- import type { JsonValue } from '@orpc/standard-server';
2
1
  import { Readable } from 'node:stream';
3
- export declare function toEventIterator(stream: Readable): AsyncGenerator<JsonValue | void, JsonValue | void, void>;
4
- export declare function toEventStream(iterator: AsyncIterator<JsonValue | void, JsonValue | void, void>): Readable;
2
+ export declare function toEventIterator(stream: Readable): AsyncGenerator<unknown | void, unknown | void, void>;
3
+ export declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>): Readable;
5
4
  //# sourceMappingURL=event-source.d.ts.map
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.b2e67f7",
4
+ "version": "0.0.0-next.fea68c1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -28,7 +28,8 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@orpc/standard-server": "0.0.0-next.b2e67f7"
31
+ "@orpc/shared": "0.0.0-next.fea68c1",
32
+ "@orpc/standard-server": "0.0.0-next.fea68c1"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/node": "^22.13.1",