@orpc/server 0.0.0-next.d16a1b6 → 0.0.0-next.d17ef5e
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 +13 -1
- package/dist/adapters/fetch/index.d.mts +26 -11
- package/dist/adapters/fetch/index.d.ts +26 -11
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/hono/index.d.mts +6 -4
- package/dist/adapters/hono/index.d.ts +6 -4
- package/dist/adapters/hono/index.mjs +6 -6
- package/dist/adapters/next/index.d.mts +6 -4
- package/dist/adapters/next/index.d.ts +6 -4
- package/dist/adapters/next/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +28 -22
- package/dist/adapters/node/index.d.ts +28 -22
- package/dist/adapters/node/index.mjs +45 -20
- package/dist/adapters/standard/index.d.mts +10 -13
- package/dist/adapters/standard/index.d.ts +10 -13
- package/dist/adapters/standard/index.mjs +2 -4
- package/dist/index.d.mts +140 -118
- package/dist/index.d.ts +140 -118
- package/dist/index.mjs +55 -46
- package/dist/plugins/index.d.mts +14 -15
- package/dist/plugins/index.d.ts +14 -15
- package/dist/plugins/index.mjs +1 -2
- package/dist/shared/{server.B-ewprcf.d.ts → server.23VRZIfj.d.ts} +19 -30
- package/dist/shared/server.BG5ftPWa.d.ts +10 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/{server.V6zT5iYQ.mjs → server.BtxZnWJ9.mjs} +155 -160
- package/dist/shared/server.C-CCcROC.d.mts +10 -0
- package/dist/shared/server.CIbpOMZX.d.mts +8 -0
- package/dist/shared/server.CTt4UYhI.mjs +51 -0
- package/dist/shared/{server.BBGuTxHE.mjs → server.CVNC_Jz8.mjs} +38 -44
- package/dist/shared/server.DCcCuA52.d.ts +8 -0
- package/dist/shared/{server.DJrh0Ceu.d.mts → server.DJqfB27m.d.mts} +19 -30
- package/dist/shared/server.MZvbGc3n.d.mts +143 -0
- package/dist/shared/server.MZvbGc3n.d.ts +143 -0
- package/package.json +8 -8
- package/dist/shared/server.CA-o8cUY.d.mts +0 -9
- package/dist/shared/server.Cn9ybJtE.d.mts +0 -152
- package/dist/shared/server.Cn9ybJtE.d.ts +0 -152
- package/dist/shared/server.DPQt9YYq.d.ts +0 -9
- package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
- package/dist/shared/server.pW-fRQNZ.mjs +0 -24
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,9 +55,13 @@ 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/server`
|
63
67
|
|
@@ -113,6 +117,14 @@ export const createPlanet = os
|
|
113
117
|
export const router = { planet: { list: listPlanet, find: findPlanet, create: createPlanet } }
|
114
118
|
```
|
115
119
|
|
120
|
+
## Sponsors
|
121
|
+
|
122
|
+
<p align="center">
|
123
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
124
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
125
|
+
</a>
|
126
|
+
</p>
|
127
|
+
|
116
128
|
## License
|
117
129
|
|
118
130
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
@@ -1,11 +1,13 @@
|
|
1
|
-
import {
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.mjs';
|
2
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.DJqfB27m.mjs';
|
3
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.C-CCcROC.mjs';
|
2
5
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import {
|
4
|
-
import { S as StandardHandleOptions } from '../../shared/server.DJrh0Ceu.mjs';
|
5
|
-
import { R as RPCHandlerOptions } from '../../shared/server.CA-o8cUY.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
|
6
7
|
import '@orpc/client';
|
7
8
|
import '@orpc/contract';
|
8
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
9
11
|
|
10
12
|
type FetchHandleResult = {
|
11
13
|
matched: true;
|
@@ -14,14 +16,27 @@ type FetchHandleResult = {
|
|
14
16
|
matched: false;
|
15
17
|
response: undefined;
|
16
18
|
};
|
17
|
-
interface
|
18
|
-
|
19
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
19
21
|
}
|
20
|
-
|
21
|
-
|
22
|
+
interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
23
|
+
request: Request;
|
24
|
+
toFetchResponseOptions: ToFetchResponseOptions;
|
25
|
+
}
|
26
|
+
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
|
27
|
+
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, unknown>[];
|
28
|
+
plugins?: FetchHandlerPlugin<T>[];
|
29
|
+
}
|
30
|
+
declare class FetchHandler<T extends Context> {
|
22
31
|
private readonly standardHandler;
|
23
|
-
|
24
|
-
|
32
|
+
private readonly toFetchResponseOptions;
|
33
|
+
private readonly adapterInterceptors;
|
34
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
35
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
36
|
+
}
|
37
|
+
|
38
|
+
declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
39
|
+
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
25
40
|
}
|
26
41
|
|
27
|
-
export { type FetchHandleResult, type
|
42
|
+
export { type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
@@ -1,11 +1,13 @@
|
|
1
|
-
import {
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.js';
|
2
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.23VRZIfj.js';
|
3
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.BG5ftPWa.js';
|
2
5
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import {
|
4
|
-
import { S as StandardHandleOptions } from '../../shared/server.B-ewprcf.js';
|
5
|
-
import { R as RPCHandlerOptions } from '../../shared/server.DPQt9YYq.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
|
6
7
|
import '@orpc/client';
|
7
8
|
import '@orpc/contract';
|
8
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
9
11
|
|
10
12
|
type FetchHandleResult = {
|
11
13
|
matched: true;
|
@@ -14,14 +16,27 @@ type FetchHandleResult = {
|
|
14
16
|
matched: false;
|
15
17
|
response: undefined;
|
16
18
|
};
|
17
|
-
interface
|
18
|
-
|
19
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
19
21
|
}
|
20
|
-
|
21
|
-
|
22
|
+
interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
23
|
+
request: Request;
|
24
|
+
toFetchResponseOptions: ToFetchResponseOptions;
|
25
|
+
}
|
26
|
+
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
|
27
|
+
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, unknown>[];
|
28
|
+
plugins?: FetchHandlerPlugin<T>[];
|
29
|
+
}
|
30
|
+
declare class FetchHandler<T extends Context> {
|
22
31
|
private readonly standardHandler;
|
23
|
-
|
24
|
-
|
32
|
+
private readonly toFetchResponseOptions;
|
33
|
+
private readonly adapterInterceptors;
|
34
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
35
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
36
|
+
}
|
37
|
+
|
38
|
+
declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
39
|
+
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
25
40
|
}
|
26
41
|
|
27
|
-
export { type FetchHandleResult, type
|
42
|
+
export { type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
2
|
-
import '@orpc/standard
|
3
|
-
import '../../shared/server.
|
1
|
+
export { F as FetchHandler, R as RPCHandler } from '../../shared/server.CTt4UYhI.mjs';
|
2
|
+
import '@orpc/client/standard';
|
3
|
+
import '../../shared/server.CVNC_Jz8.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/shared';
|
6
|
-
import '../../shared/server.
|
7
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
6
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
8
7
|
import '@orpc/contract';
|
9
|
-
import '@orpc/
|
8
|
+
import '@orpc/standard-server-fetch';
|
9
|
+
import '../../shared/server.BVwwTHyO.mjs';
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.mjs';
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
2
|
+
export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DJqfB27m.mjs';
|
7
|
+
import '../../shared/server.C-CCcROC.mjs';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.CIbpOMZX.mjs';
|
10
|
+
import '@orpc/client/standard';
|
9
11
|
import '@orpc/client';
|
10
12
|
import '@orpc/contract';
|
11
13
|
import '@orpc/standard-server';
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.js';
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
2
|
+
export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.23VRZIfj.js';
|
7
|
+
import '../../shared/server.BG5ftPWa.js';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DCcCuA52.js';
|
10
|
+
import '@orpc/client/standard';
|
9
11
|
import '@orpc/client';
|
10
12
|
import '@orpc/contract';
|
11
13
|
import '@orpc/standard-server';
|
@@ -1,12 +1,12 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { F as FetchHandler, R as RPCHandler } from '../../shared/server.CTt4UYhI.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
|
-
import '@orpc/standard
|
4
|
-
import '../../shared/server.
|
3
|
+
import '@orpc/client/standard';
|
4
|
+
import '../../shared/server.CVNC_Jz8.mjs';
|
5
5
|
import '@orpc/client';
|
6
|
-
import '../../shared/server.
|
7
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
6
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
8
7
|
import '@orpc/contract';
|
9
|
-
import '@orpc/
|
8
|
+
import '@orpc/standard-server-fetch';
|
9
|
+
import '../../shared/server.BVwwTHyO.mjs';
|
10
10
|
|
11
11
|
function createMiddleware(handler, ...[options]) {
|
12
12
|
return async (c, next) => {
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.mjs';
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
2
|
+
export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DJqfB27m.mjs';
|
7
|
+
import '../../shared/server.C-CCcROC.mjs';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.CIbpOMZX.mjs';
|
10
|
+
import '@orpc/client/standard';
|
9
11
|
import '@orpc/client';
|
10
12
|
import '@orpc/contract';
|
11
13
|
import '@orpc/standard-server';
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.js';
|
2
|
-
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
2
|
+
export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.23VRZIfj.js';
|
7
|
+
import '../../shared/server.BG5ftPWa.js';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DCcCuA52.js';
|
10
|
+
import '@orpc/client/standard';
|
9
11
|
import '@orpc/client';
|
10
12
|
import '@orpc/contract';
|
11
13
|
import '@orpc/standard-server';
|
@@ -1,12 +1,12 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { F as FetchHandler, R as RPCHandler } from '../../shared/server.CTt4UYhI.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
|
-
import '@orpc/standard
|
4
|
-
import '../../shared/server.
|
3
|
+
import '@orpc/client/standard';
|
4
|
+
import '../../shared/server.CVNC_Jz8.mjs';
|
5
5
|
import '@orpc/client';
|
6
|
-
import '../../shared/server.
|
7
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
6
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
8
7
|
import '@orpc/contract';
|
9
|
-
import '@orpc/
|
8
|
+
import '@orpc/standard-server-fetch';
|
9
|
+
import '../../shared/server.BVwwTHyO.mjs';
|
10
10
|
|
11
11
|
function serve(handler, ...[options]) {
|
12
12
|
const main = async (req) => {
|
@@ -1,35 +1,41 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
1
|
+
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.mjs';
|
3
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.DJqfB27m.mjs';
|
4
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.C-CCcROC.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
|
8
7
|
import '@orpc/client';
|
9
8
|
import '@orpc/contract';
|
10
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
11
11
|
|
12
|
-
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
13
|
-
/**
|
14
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
15
|
-
* This is useful for `express.js` middleware.
|
16
|
-
*/
|
17
|
-
originalUrl?: string;
|
18
|
-
};
|
19
|
-
type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
20
12
|
type NodeHttpHandleResult = {
|
21
13
|
matched: true;
|
22
14
|
} | {
|
23
15
|
matched: false;
|
24
16
|
};
|
25
|
-
interface
|
26
|
-
|
17
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
27
19
|
}
|
28
|
-
|
29
|
-
|
20
|
+
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
21
|
+
adapterInterceptors?: Interceptor<{
|
22
|
+
request: NodeHttpRequest;
|
23
|
+
response: NodeHttpResponse;
|
24
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
25
|
+
options: StandardHandleOptions<T>;
|
26
|
+
}, NodeHttpHandleResult, unknown>[];
|
27
|
+
plugins?: NodeHttpHandlerPlugin<T>[];
|
28
|
+
}
|
29
|
+
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
30
30
|
private readonly standardHandler;
|
31
|
-
|
32
|
-
|
31
|
+
private readonly sendStandardResponseOptions;
|
32
|
+
private readonly adapterInterceptors;
|
33
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>);
|
34
|
+
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
35
|
+
}
|
36
|
+
|
37
|
+
declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
38
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
33
39
|
}
|
34
40
|
|
35
|
-
export { type NodeHttpHandleResult,
|
41
|
+
export { type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,35 +1,41 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
1
|
+
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.js';
|
3
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.23VRZIfj.js';
|
4
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.BG5ftPWa.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
|
8
7
|
import '@orpc/client';
|
9
8
|
import '@orpc/contract';
|
10
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
11
11
|
|
12
|
-
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
13
|
-
/**
|
14
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
15
|
-
* This is useful for `express.js` middleware.
|
16
|
-
*/
|
17
|
-
originalUrl?: string;
|
18
|
-
};
|
19
|
-
type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
20
12
|
type NodeHttpHandleResult = {
|
21
13
|
matched: true;
|
22
14
|
} | {
|
23
15
|
matched: false;
|
24
16
|
};
|
25
|
-
interface
|
26
|
-
|
17
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
27
19
|
}
|
28
|
-
|
29
|
-
|
20
|
+
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
21
|
+
adapterInterceptors?: Interceptor<{
|
22
|
+
request: NodeHttpRequest;
|
23
|
+
response: NodeHttpResponse;
|
24
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
25
|
+
options: StandardHandleOptions<T>;
|
26
|
+
}, NodeHttpHandleResult, unknown>[];
|
27
|
+
plugins?: NodeHttpHandlerPlugin<T>[];
|
28
|
+
}
|
29
|
+
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
30
30
|
private readonly standardHandler;
|
31
|
-
|
32
|
-
|
31
|
+
private readonly sendStandardResponseOptions;
|
32
|
+
private readonly adapterInterceptors;
|
33
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>);
|
34
|
+
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
35
|
+
}
|
36
|
+
|
37
|
+
declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
38
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
33
39
|
}
|
34
40
|
|
35
|
-
export { type NodeHttpHandleResult,
|
41
|
+
export { type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,28 +1,53 @@
|
|
1
|
+
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
2
|
-
import {
|
3
|
+
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.BVwwTHyO.mjs';
|
4
|
+
import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
5
|
+
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from '../../shared/server.CVNC_Jz8.mjs';
|
3
6
|
import '@orpc/client';
|
4
|
-
import '
|
5
|
-
import '../../shared/server.Q6ZmnTgO.mjs';
|
6
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
7
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
7
8
|
import '@orpc/contract';
|
8
|
-
import '@orpc/client/standard';
|
9
9
|
|
10
|
-
class
|
11
|
-
standardHandler
|
12
|
-
|
13
|
-
const
|
14
|
-
|
15
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
16
|
-
}
|
17
|
-
async handle(req, res, ...[options]) {
|
18
|
-
const standardRequest = toStandardLazyRequest(req, res);
|
19
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
20
|
-
if (!result.matched) {
|
21
|
-
return { matched: false };
|
10
|
+
class NodeHttpHandler {
|
11
|
+
constructor(standardHandler, options = {}) {
|
12
|
+
this.standardHandler = standardHandler;
|
13
|
+
for (const plugin of toArray(options.plugins)) {
|
14
|
+
plugin.initRuntimeAdapter?.(options);
|
22
15
|
}
|
23
|
-
|
24
|
-
|
16
|
+
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
17
|
+
this.sendStandardResponseOptions = options;
|
18
|
+
}
|
19
|
+
sendStandardResponseOptions;
|
20
|
+
adapterInterceptors;
|
21
|
+
async handle(request, response, ...rest) {
|
22
|
+
return intercept(
|
23
|
+
this.adapterInterceptors,
|
24
|
+
{
|
25
|
+
request,
|
26
|
+
response,
|
27
|
+
sendStandardResponseOptions: this.sendStandardResponseOptions,
|
28
|
+
options: resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest))
|
29
|
+
},
|
30
|
+
async ({ request: request2, response: response2, sendStandardResponseOptions, options }) => {
|
31
|
+
const standardRequest = toStandardLazyRequest(request2, response2);
|
32
|
+
const result = await this.standardHandler.handle(standardRequest, options);
|
33
|
+
if (!result.matched) {
|
34
|
+
return { matched: false };
|
35
|
+
}
|
36
|
+
await sendStandardResponse(response2, result.response, sendStandardResponseOptions);
|
37
|
+
return { matched: true };
|
38
|
+
}
|
39
|
+
);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
class RPCHandler extends NodeHttpHandler {
|
44
|
+
constructor(router, options = {}) {
|
45
|
+
const jsonSerializer = new StandardRPCJsonSerializer(options);
|
46
|
+
const serializer = new StandardRPCSerializer(jsonSerializer);
|
47
|
+
const matcher = new StandardRPCMatcher();
|
48
|
+
const codec = new StandardRPCCodec(serializer);
|
49
|
+
super(new StandardHandler(router, matcher, codec, options), options);
|
25
50
|
}
|
26
51
|
}
|
27
52
|
|
28
|
-
export { RPCHandler };
|
53
|
+
export { NodeHttpHandler, RPCHandler };
|
@@ -1,29 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
export { S as StandardHandleOptions,
|
1
|
+
import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.DJqfB27m.mjs';
|
2
|
+
export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.DJqfB27m.mjs';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
|
+
import { StandardRPCSerializer } from '@orpc/client/standard';
|
4
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
5
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
-
|
7
|
-
export { R as RPCHandlerOptions } from '../../shared/server.CA-o8cUY.mjs';
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.mjs';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
|
8
8
|
import { HTTPPath } from '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
11
|
-
|
12
|
-
serializer?: RPCSerializer;
|
13
|
-
}
|
14
|
-
declare class RPCCodec implements StandardCodec {
|
11
|
+
declare class StandardRPCCodec implements StandardCodec {
|
15
12
|
private readonly serializer;
|
16
|
-
constructor(
|
13
|
+
constructor(serializer: StandardRPCSerializer);
|
17
14
|
decode(request: StandardLazyRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
18
15
|
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
19
16
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
20
17
|
}
|
21
18
|
|
22
|
-
declare class
|
19
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
23
20
|
private readonly tree;
|
24
21
|
private pendingRouters;
|
25
|
-
init(router: AnyRouter, path?: string[]): void;
|
22
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
26
23
|
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
27
24
|
}
|
28
25
|
|
29
|
-
export {
|
26
|
+
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
@@ -1,29 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
export { S as StandardHandleOptions,
|
1
|
+
import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.23VRZIfj.js';
|
2
|
+
export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.23VRZIfj.js';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
|
+
import { StandardRPCSerializer } from '@orpc/client/standard';
|
4
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
5
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
-
|
7
|
-
export { R as RPCHandlerOptions } from '../../shared/server.DPQt9YYq.js';
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.js';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
|
8
8
|
import { HTTPPath } from '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
11
|
-
|
12
|
-
serializer?: RPCSerializer;
|
13
|
-
}
|
14
|
-
declare class RPCCodec implements StandardCodec {
|
11
|
+
declare class StandardRPCCodec implements StandardCodec {
|
15
12
|
private readonly serializer;
|
16
|
-
constructor(
|
13
|
+
constructor(serializer: StandardRPCSerializer);
|
17
14
|
decode(request: StandardLazyRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
18
15
|
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
19
16
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
20
17
|
}
|
21
18
|
|
22
|
-
declare class
|
19
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
23
20
|
private readonly tree;
|
24
21
|
private pendingRouters;
|
25
|
-
init(router: AnyRouter, path?: string[]): void;
|
22
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
26
23
|
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
27
24
|
}
|
28
25
|
|
29
|
-
export {
|
26
|
+
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
@@ -1,7 +1,5 @@
|
|
1
|
-
export {
|
1
|
+
export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.CVNC_Jz8.mjs';
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/shared';
|
4
|
-
import '../../shared/server.
|
5
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
4
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
6
5
|
import '@orpc/contract';
|
7
|
-
import '@orpc/client/standard';
|