@orpc/server 0.0.0-next.93e6063 → 0.0.0-next.9486ab5
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 +14 -1
- package/dist/adapters/fetch/index.d.mts +38 -11
- package/dist/adapters/fetch/index.d.ts +38 -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 +40 -22
- package/dist/adapters/node/index.d.ts +40 -22
- package/dist/adapters/node/index.mjs +77 -22
- package/dist/adapters/standard/index.d.mts +12 -15
- package/dist/adapters/standard/index.d.ts +12 -15
- package/dist/adapters/standard/index.mjs +2 -3
- package/dist/index.d.mts +156 -120
- package/dist/index.d.ts +156 -120
- package/dist/index.mjs +78 -48
- package/dist/plugins/index.d.mts +15 -16
- package/dist/plugins/index.d.ts +15 -16
- package/dist/plugins/index.mjs +10 -6
- package/dist/shared/server.89QkKw3a.d.mts +10 -0
- package/dist/shared/server.B1S3zwuw.d.mts +8 -0
- package/dist/shared/server.BMkFIQUb.d.mts +66 -0
- package/dist/shared/server.BT0gne12.d.ts +8 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/{server.V6zT5iYQ.mjs → server.CjWkNG6l.mjs} +151 -160
- package/dist/shared/server.D0YVcfZk.d.mts +143 -0
- package/dist/shared/server.D0YVcfZk.d.ts +143 -0
- package/dist/shared/{server.BBGuTxHE.mjs → server.D9QduY95.mjs} +43 -45
- package/dist/shared/server.Et1O6Bm7.mjs +98 -0
- package/dist/shared/server.taqJyaMn.d.ts +10 -0
- package/dist/shared/server.ywWqDZgA.d.ts +66 -0
- package/package.json +8 -8
- package/dist/shared/server.B-ewprcf.d.ts +0 -77
- 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.DJrh0Ceu.d.mts +0 -77
- package/dist/shared/server.DPQt9YYq.d.ts +0 -9
- package/dist/shared/server.KwueCzFr.mjs +0 -26
- package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
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,11 +53,16 @@ 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/server`
|
63
68
|
|
@@ -113,6 +118,14 @@ export const createPlanet = os
|
|
113
118
|
export const router = { planet: { list: listPlanet, find: findPlanet, create: createPlanet } }
|
114
119
|
```
|
115
120
|
|
121
|
+
## Sponsors
|
122
|
+
|
123
|
+
<p align="center">
|
124
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
125
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
126
|
+
</a>
|
127
|
+
</p>
|
128
|
+
|
116
129
|
## License
|
117
130
|
|
118
131
|
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.D0YVcfZk.mjs';
|
2
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BMkFIQUb.mjs';
|
3
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.89QkKw3a.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.B1S3zwuw.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,39 @@ 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
|
+
interface BodyLimitPluginOptions {
|
39
|
+
/**
|
40
|
+
* The maximum size of the body in bytes.
|
41
|
+
*/
|
42
|
+
maxBodySize: number;
|
43
|
+
}
|
44
|
+
declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
45
|
+
private readonly maxBodySize;
|
46
|
+
constructor(options: BodyLimitPluginOptions);
|
47
|
+
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
48
|
+
}
|
49
|
+
|
50
|
+
declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
51
|
+
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
25
52
|
}
|
26
53
|
|
27
|
-
export { type
|
54
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, 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.D0YVcfZk.js';
|
2
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.ywWqDZgA.js';
|
3
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.taqJyaMn.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.BT0gne12.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,39 @@ 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
|
+
interface BodyLimitPluginOptions {
|
39
|
+
/**
|
40
|
+
* The maximum size of the body in bytes.
|
41
|
+
*/
|
42
|
+
maxBodySize: number;
|
43
|
+
}
|
44
|
+
declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
45
|
+
private readonly maxBodySize;
|
46
|
+
constructor(options: BodyLimitPluginOptions);
|
47
|
+
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
48
|
+
}
|
49
|
+
|
50
|
+
declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
51
|
+
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
25
52
|
}
|
26
53
|
|
27
|
-
export { type
|
54
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, 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-server-fetch';
|
3
|
-
import '../../shared/server.BBGuTxHE.mjs';
|
1
|
+
export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Et1O6Bm7.mjs';
|
4
2
|
import '@orpc/client';
|
3
|
+
import '@orpc/client/standard';
|
4
|
+
import '../../shared/server.D9QduY95.mjs';
|
5
5
|
import '@orpc/shared';
|
6
|
-
import '../../shared/server.
|
7
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
6
|
+
import '../../shared/server.CjWkNG6l.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 { BodyLimitPlugin, BodyLimitPluginOptions, 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.D0YVcfZk.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.BMkFIQUb.mjs';
|
7
|
+
import '../../shared/server.89QkKw3a.mjs';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.B1S3zwuw.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 { BodyLimitPlugin, BodyLimitPluginOptions, 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.D0YVcfZk.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.ywWqDZgA.js';
|
7
|
+
import '../../shared/server.taqJyaMn.js';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.BT0gne12.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 { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Et1O6Bm7.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
|
-
import '@orpc/standard-server-fetch';
|
4
|
-
import '../../shared/server.BBGuTxHE.mjs';
|
5
3
|
import '@orpc/client';
|
6
|
-
import '../../shared/server.Q6ZmnTgO.mjs';
|
7
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
8
|
-
import '@orpc/contract';
|
9
4
|
import '@orpc/client/standard';
|
5
|
+
import '../../shared/server.D9QduY95.mjs';
|
6
|
+
import '../../shared/server.CjWkNG6l.mjs';
|
7
|
+
import '@orpc/contract';
|
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 { BodyLimitPlugin, BodyLimitPluginOptions, 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.D0YVcfZk.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.BMkFIQUb.mjs';
|
7
|
+
import '../../shared/server.89QkKw3a.mjs';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.B1S3zwuw.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 { BodyLimitPlugin, BodyLimitPluginOptions, 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.D0YVcfZk.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.ywWqDZgA.js';
|
7
|
+
import '../../shared/server.taqJyaMn.js';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.BT0gne12.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 { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Et1O6Bm7.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
|
-
import '@orpc/standard-server-fetch';
|
4
|
-
import '../../shared/server.BBGuTxHE.mjs';
|
5
3
|
import '@orpc/client';
|
6
|
-
import '../../shared/server.Q6ZmnTgO.mjs';
|
7
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
8
|
-
import '@orpc/contract';
|
9
4
|
import '@orpc/client/standard';
|
5
|
+
import '../../shared/server.D9QduY95.mjs';
|
6
|
+
import '../../shared/server.CjWkNG6l.mjs';
|
7
|
+
import '@orpc/contract';
|
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,53 @@
|
|
1
|
-
import {
|
2
|
-
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.D0YVcfZk.mjs';
|
2
|
+
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
3
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BMkFIQUb.mjs';
|
4
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.89QkKw3a.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.B1S3zwuw.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 NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
21
|
+
request: NodeHttpRequest;
|
22
|
+
response: NodeHttpResponse;
|
23
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
24
|
+
}
|
25
|
+
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
26
|
+
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, 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
|
+
interface BodyLimitPluginOptions {
|
38
|
+
/**
|
39
|
+
* The maximum size of the body in bytes.
|
40
|
+
*/
|
41
|
+
maxBodySize: number;
|
42
|
+
}
|
43
|
+
declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
44
|
+
private readonly maxBodySize;
|
45
|
+
constructor(options: BodyLimitPluginOptions);
|
46
|
+
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
47
|
+
}
|
48
|
+
|
49
|
+
declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
50
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
33
51
|
}
|
34
52
|
|
35
|
-
export { type
|
53
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,35 +1,53 @@
|
|
1
|
-
import {
|
2
|
-
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.D0YVcfZk.js';
|
2
|
+
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
3
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.ywWqDZgA.js';
|
4
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.taqJyaMn.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BT0gne12.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 NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
21
|
+
request: NodeHttpRequest;
|
22
|
+
response: NodeHttpResponse;
|
23
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
24
|
+
}
|
25
|
+
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
26
|
+
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, 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
|
+
interface BodyLimitPluginOptions {
|
38
|
+
/**
|
39
|
+
* The maximum size of the body in bytes.
|
40
|
+
*/
|
41
|
+
maxBodySize: number;
|
42
|
+
}
|
43
|
+
declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
44
|
+
private readonly maxBodySize;
|
45
|
+
constructor(options: BodyLimitPluginOptions);
|
46
|
+
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
47
|
+
}
|
48
|
+
|
49
|
+
declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
50
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
33
51
|
}
|
34
52
|
|
35
|
-
export { type
|
53
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,30 +1,85 @@
|
|
1
|
+
import { ORPCError } from '@orpc/client';
|
2
|
+
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
3
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
2
|
-
import {
|
3
|
-
import '@orpc/client';
|
4
|
-
import '
|
5
|
-
import '../../shared/server.
|
6
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
4
|
+
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.BVwwTHyO.mjs';
|
5
|
+
import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
6
|
+
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from '../../shared/server.D9QduY95.mjs';
|
7
|
+
import '../../shared/server.CjWkNG6l.mjs';
|
7
8
|
import '@orpc/contract';
|
8
|
-
import '@orpc/client/standard';
|
9
9
|
|
10
|
-
class
|
11
|
-
|
12
|
-
constructor(
|
13
|
-
|
14
|
-
const matcher = options?.matcher ?? new RPCMatcher();
|
15
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
10
|
+
class BodyLimitPlugin {
|
11
|
+
maxBodySize;
|
12
|
+
constructor(options) {
|
13
|
+
this.maxBodySize = options.maxBodySize;
|
16
14
|
}
|
17
|
-
|
18
|
-
options
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
initRuntimeAdapter(options) {
|
16
|
+
options.adapterInterceptors ??= [];
|
17
|
+
options.adapterInterceptors.push(async (options2) => {
|
18
|
+
let isHeaderChecked = false;
|
19
|
+
const checkHeader = () => {
|
20
|
+
if (!isHeaderChecked && Number(options2.request.headers["content-length"]) > this.maxBodySize) {
|
21
|
+
throw new ORPCError("PAYLOAD_TOO_LARGE");
|
22
|
+
}
|
23
|
+
isHeaderChecked = true;
|
24
|
+
};
|
25
|
+
const originalEmit = options2.request.emit.bind(options2.request);
|
26
|
+
let currentBodySize = 0;
|
27
|
+
options2.request.emit = (event, ...args) => {
|
28
|
+
if (event === "data") {
|
29
|
+
checkHeader();
|
30
|
+
currentBodySize += args[0].length;
|
31
|
+
if (currentBodySize > this.maxBodySize) {
|
32
|
+
throw new ORPCError("PAYLOAD_TOO_LARGE");
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return originalEmit(event, ...args);
|
36
|
+
};
|
37
|
+
return options2.next();
|
38
|
+
});
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
class NodeHttpHandler {
|
43
|
+
constructor(standardHandler, options = {}) {
|
44
|
+
this.standardHandler = standardHandler;
|
45
|
+
for (const plugin of toArray(options.plugins)) {
|
46
|
+
plugin.initRuntimeAdapter?.(options);
|
24
47
|
}
|
25
|
-
|
26
|
-
|
48
|
+
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
49
|
+
this.sendStandardResponseOptions = options;
|
50
|
+
}
|
51
|
+
sendStandardResponseOptions;
|
52
|
+
adapterInterceptors;
|
53
|
+
async handle(request, response, ...rest) {
|
54
|
+
return intercept(
|
55
|
+
this.adapterInterceptors,
|
56
|
+
{
|
57
|
+
...resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest)),
|
58
|
+
request,
|
59
|
+
response,
|
60
|
+
sendStandardResponseOptions: this.sendStandardResponseOptions
|
61
|
+
},
|
62
|
+
async ({ request: request2, response: response2, sendStandardResponseOptions, ...options }) => {
|
63
|
+
const standardRequest = toStandardLazyRequest(request2, response2);
|
64
|
+
const result = await this.standardHandler.handle(standardRequest, options);
|
65
|
+
if (!result.matched) {
|
66
|
+
return { matched: false };
|
67
|
+
}
|
68
|
+
await sendStandardResponse(response2, result.response, sendStandardResponseOptions);
|
69
|
+
return { matched: true };
|
70
|
+
}
|
71
|
+
);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
class RPCHandler extends NodeHttpHandler {
|
76
|
+
constructor(router, options = {}) {
|
77
|
+
const jsonSerializer = new StandardRPCJsonSerializer(options);
|
78
|
+
const serializer = new StandardRPCSerializer(jsonSerializer);
|
79
|
+
const matcher = new StandardRPCMatcher();
|
80
|
+
const codec = new StandardRPCCodec(serializer);
|
81
|
+
super(new StandardHandler(router, matcher, codec, options), options);
|
27
82
|
}
|
28
83
|
}
|
29
84
|
|
30
|
-
export { RPCHandler };
|
85
|
+
export { BodyLimitPlugin, NodeHttpHandler, RPCHandler };
|
@@ -1,29 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
export { S as StandardHandleOptions,
|
3
|
-
import { ORPCError } from '@orpc/client';
|
1
|
+
import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.BMkFIQUb.mjs';
|
2
|
+
export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.BMkFIQUb.mjs';
|
3
|
+
import { ORPCError, HTTPPath } 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
|
-
|
8
|
-
import { HTTPPath } from '@orpc/contract';
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.D0YVcfZk.mjs';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.B1S3zwuw.mjs';
|
8
|
+
import '@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 };
|