@orpc/standard-server-node 0.0.0-next.f4d410a → 0.0.0-next.f635909
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 +24 -17
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +16 -18
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -21,28 +21,24 @@
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
23
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
|
|
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
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
28
|
## Highlights
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
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.
|
|
30
|
+
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
|
+
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
|
+
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
34
|
+
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
|
+
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
|
+
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
37
|
+
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
|
|
38
|
+
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
|
+
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
|
+
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
+
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
46
42
|
|
|
47
43
|
## Documentation
|
|
48
44
|
|
|
@@ -53,6 +49,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
53
49
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
54
50
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
55
51
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
53
|
- [@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
54
|
- [@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
55
|
- [@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 +57,21 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
60
57
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
61
58
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
62
59
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
60
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
61
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
63
62
|
|
|
64
63
|
## `@orpc/standard-server-node`
|
|
65
64
|
|
|
66
65
|
[Node.js](https://nodejs.org) server adapter for oRPC.
|
|
67
66
|
|
|
67
|
+
## Sponsors
|
|
68
|
+
|
|
69
|
+
<p align="center">
|
|
70
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
|
71
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
|
72
|
+
</a>
|
|
73
|
+
</p>
|
|
74
|
+
|
|
68
75
|
## License
|
|
69
76
|
|
|
70
77
|
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 @@ 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) {
|
|
@@ -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,
|
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.
|
|
4
|
+
"version": "0.0.0-next.f635909",
|
|
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/shared": "0.0.0-next.
|
|
27
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
26
|
+
"@orpc/shared": "0.0.0-next.f635909",
|
|
27
|
+
"@orpc/standard-server": "0.0.0-next.f635909"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/node": "^22.
|
|
31
|
-
"@types/supertest": "^6.0.
|
|
32
|
-
"supertest": "^7.
|
|
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",
|