@orpc/server 0.0.0-next.e98b833 → 0.0.0-next.ea0903c
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 +12 -1
- package/dist/adapters/fetch/index.d.mts +38 -10
- package/dist/adapters/fetch/index.d.ts +38 -10
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/hono/index.d.mts +6 -3
- package/dist/adapters/hono/index.d.ts +6 -3
- package/dist/adapters/hono/index.mjs +6 -6
- package/dist/adapters/next/index.d.mts +6 -3
- package/dist/adapters/next/index.d.ts +6 -3
- package/dist/adapters/next/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +40 -21
- package/dist/adapters/node/index.d.ts +40 -21
- package/dist/adapters/node/index.mjs +77 -23
- package/dist/adapters/standard/index.d.mts +11 -10
- package/dist/adapters/standard/index.d.ts +11 -10
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +55 -49
- package/dist/index.d.ts +55 -49
- package/dist/index.mjs +21 -22
- package/dist/plugins/index.d.mts +12 -13
- package/dist/plugins/index.d.ts +12 -13
- package/dist/plugins/index.mjs +9 -5
- package/dist/shared/server.89QkKw3a.d.mts +10 -0
- package/dist/shared/server.B1S3zwuw.d.mts +8 -0
- package/dist/shared/{server.DmW25ynm.d.ts → server.BMkFIQUb.d.mts} +17 -26
- package/dist/shared/server.BT0gne12.d.ts +8 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/{server.CMrS28Go.mjs → server.CjWkNG6l.mjs} +35 -11
- package/dist/shared/{server.CPteJIPP.d.mts → server.D0YVcfZk.d.mts} +13 -13
- package/dist/shared/{server.CPteJIPP.d.ts → server.D0YVcfZk.d.ts} +13 -13
- package/dist/shared/{server.CSZRzcSW.mjs → server.D9QduY95.mjs} +33 -30
- package/dist/shared/server.Et1O6Bm7.mjs +98 -0
- package/dist/shared/server.taqJyaMn.d.ts +10 -0
- package/dist/shared/{server.CM3tWr3C.d.mts → server.ywWqDZgA.d.ts} +17 -26
- package/package.json +8 -8
- package/dist/shared/server.Cq3B6PoL.mjs +0 -28
- 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, Solid), 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.
|
@@ -56,9 +56,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
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
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).
|
59
60
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
60
61
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
61
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/).
|
62
65
|
|
63
66
|
## `@orpc/server`
|
64
67
|
|
@@ -114,6 +117,14 @@ export const createPlanet = os
|
|
114
117
|
export const router = { planet: { list: listPlanet, find: findPlanet, create: createPlanet } }
|
115
118
|
```
|
116
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
|
+
|
117
128
|
## License
|
118
129
|
|
119
130
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
@@ -1,10 +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, b as StandardHandlerOptions } from '../../shared/server.CM3tWr3C.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.B1S3zwuw.mjs';
|
5
7
|
import '@orpc/client';
|
6
8
|
import '@orpc/contract';
|
7
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
8
11
|
|
9
12
|
type FetchHandleResult = {
|
10
13
|
matched: true;
|
@@ -13,14 +16,39 @@ type FetchHandleResult = {
|
|
13
16
|
matched: false;
|
14
17
|
response: undefined;
|
15
18
|
};
|
16
|
-
interface
|
17
|
-
|
19
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
18
21
|
}
|
19
|
-
|
20
|
-
|
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> {
|
21
31
|
private readonly standardHandler;
|
22
|
-
|
23
|
-
|
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>>);
|
24
52
|
}
|
25
53
|
|
26
|
-
export { type
|
54
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
@@ -1,10 +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, b as StandardHandlerOptions } from '../../shared/server.DmW25ynm.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BT0gne12.js';
|
5
7
|
import '@orpc/client';
|
6
8
|
import '@orpc/contract';
|
7
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
8
11
|
|
9
12
|
type FetchHandleResult = {
|
10
13
|
matched: true;
|
@@ -13,14 +16,39 @@ type FetchHandleResult = {
|
|
13
16
|
matched: false;
|
14
17
|
response: undefined;
|
15
18
|
};
|
16
|
-
interface
|
17
|
-
|
19
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
18
21
|
}
|
19
|
-
|
20
|
-
|
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> {
|
21
31
|
private readonly standardHandler;
|
22
|
-
|
23
|
-
|
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>>);
|
24
52
|
}
|
25
53
|
|
26
|
-
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/client/standard';
|
3
|
-
import '@orpc/standard-server-fetch';
|
4
|
-
import '../../shared/server.CSZRzcSW.mjs';
|
1
|
+
export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Et1O6Bm7.mjs';
|
5
2
|
import '@orpc/client';
|
3
|
+
import '@orpc/client/standard';
|
4
|
+
import '../../shared/server.D9QduY95.mjs';
|
6
5
|
import '@orpc/shared';
|
7
|
-
import '../../shared/server.
|
8
|
-
import '../../shared/server.CMrS28Go.mjs';
|
6
|
+
import '../../shared/server.CjWkNG6l.mjs';
|
9
7
|
import '@orpc/contract';
|
8
|
+
import '@orpc/standard-server-fetch';
|
9
|
+
import '../../shared/server.BVwwTHyO.mjs';
|
@@ -1,10 +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';
|
9
|
+
import '../../shared/server.B1S3zwuw.mjs';
|
10
|
+
import '@orpc/client/standard';
|
8
11
|
import '@orpc/client';
|
9
12
|
import '@orpc/contract';
|
10
13
|
import '@orpc/standard-server';
|
@@ -1,10 +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';
|
9
|
+
import '../../shared/server.BT0gne12.js';
|
10
|
+
import '@orpc/client/standard';
|
8
11
|
import '@orpc/client';
|
9
12
|
import '@orpc/contract';
|
10
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/client/standard';
|
4
|
-
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.CSZRzcSW.mjs';
|
6
3
|
import '@orpc/client';
|
7
|
-
import '
|
8
|
-
import '../../shared/server.
|
4
|
+
import '@orpc/client/standard';
|
5
|
+
import '../../shared/server.D9QduY95.mjs';
|
6
|
+
import '../../shared/server.CjWkNG6l.mjs';
|
9
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,10 +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';
|
9
|
+
import '../../shared/server.B1S3zwuw.mjs';
|
10
|
+
import '@orpc/client/standard';
|
8
11
|
import '@orpc/client';
|
9
12
|
import '@orpc/contract';
|
10
13
|
import '@orpc/standard-server';
|
@@ -1,10 +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';
|
9
|
+
import '../../shared/server.BT0gne12.js';
|
10
|
+
import '@orpc/client/standard';
|
8
11
|
import '@orpc/client';
|
9
12
|
import '@orpc/contract';
|
10
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/client/standard';
|
4
|
-
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.CSZRzcSW.mjs';
|
6
3
|
import '@orpc/client';
|
7
|
-
import '
|
8
|
-
import '../../shared/server.
|
4
|
+
import '@orpc/client/standard';
|
5
|
+
import '../../shared/server.D9QduY95.mjs';
|
6
|
+
import '../../shared/server.CjWkNG6l.mjs';
|
9
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,34 +1,53 @@
|
|
1
|
-
import {
|
2
|
-
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
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';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
10
11
|
|
11
|
-
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
12
|
-
/**
|
13
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
14
|
-
* This is useful for `express.js` middleware.
|
15
|
-
*/
|
16
|
-
originalUrl?: string;
|
17
|
-
};
|
18
|
-
type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
19
12
|
type NodeHttpHandleResult = {
|
20
13
|
matched: true;
|
21
14
|
} | {
|
22
15
|
matched: false;
|
23
16
|
};
|
24
|
-
interface
|
25
|
-
|
17
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
26
19
|
}
|
27
|
-
|
28
|
-
|
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> {
|
29
30
|
private readonly standardHandler;
|
30
|
-
|
31
|
-
|
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>>);
|
32
51
|
}
|
33
52
|
|
34
|
-
export { type
|
53
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,34 +1,53 @@
|
|
1
|
-
import {
|
2
|
-
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
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';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/client/standard';
|
10
11
|
|
11
|
-
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
12
|
-
/**
|
13
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
14
|
-
* This is useful for `express.js` middleware.
|
15
|
-
*/
|
16
|
-
originalUrl?: string;
|
17
|
-
};
|
18
|
-
type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
19
12
|
type NodeHttpHandleResult = {
|
20
13
|
matched: true;
|
21
14
|
} | {
|
22
15
|
matched: false;
|
23
16
|
};
|
24
|
-
interface
|
25
|
-
|
17
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
26
19
|
}
|
27
|
-
|
28
|
-
|
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> {
|
29
30
|
private readonly standardHandler;
|
30
|
-
|
31
|
-
|
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>>);
|
32
51
|
}
|
33
52
|
|
34
|
-
export { type
|
53
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,31 +1,85 @@
|
|
1
|
-
import {
|
1
|
+
import { ORPCError } from '@orpc/client';
|
2
|
+
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import '@orpc/client';
|
5
|
-
import '
|
6
|
-
import '../../shared/server.
|
7
|
-
import '../../shared/server.CMrS28Go.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';
|
8
8
|
import '@orpc/contract';
|
9
9
|
|
10
|
-
class
|
11
|
-
|
12
|
-
constructor(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
class BodyLimitPlugin {
|
11
|
+
maxBodySize;
|
12
|
+
constructor(options) {
|
13
|
+
this.maxBodySize = options.maxBodySize;
|
14
|
+
}
|
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
|
+
});
|
17
39
|
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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);
|
25
47
|
}
|
26
|
-
|
27
|
-
|
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);
|
28
82
|
}
|
29
83
|
}
|
30
84
|
|
31
|
-
export { RPCHandler };
|
85
|
+
export { BodyLimitPlugin, NodeHttpHandler, RPCHandler };
|
@@ -1,25 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
export { S as StandardHandleOptions,
|
3
|
-
import { ORPCError } from '@orpc/client';
|
4
|
-
import {
|
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';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
7
|
-
|
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';
|
8
9
|
import '@orpc/shared';
|
9
10
|
|
10
|
-
declare class
|
11
|
+
declare class StandardRPCCodec implements StandardCodec {
|
11
12
|
private readonly serializer;
|
12
|
-
constructor(serializer:
|
13
|
+
constructor(serializer: StandardRPCSerializer);
|
13
14
|
decode(request: StandardLazyRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
14
15
|
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
15
16
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
16
17
|
}
|
17
18
|
|
18
|
-
declare class
|
19
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
19
20
|
private readonly tree;
|
20
21
|
private pendingRouters;
|
21
22
|
init(router: AnyRouter, path?: readonly string[]): void;
|
22
23
|
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
23
24
|
}
|
24
25
|
|
25
|
-
export {
|
26
|
+
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|