@orpc/server 1.0.0-beta.3 → 1.0.0-beta.5
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 +9 -0
- package/dist/adapters/fetch/index.d.mts +37 -11
- package/dist/adapters/fetch/index.d.ts +37 -11
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/hono/index.d.mts +5 -4
- package/dist/adapters/hono/index.d.ts +5 -4
- package/dist/adapters/hono/index.mjs +6 -6
- package/dist/adapters/next/index.d.mts +5 -4
- package/dist/adapters/next/index.d.ts +5 -4
- package/dist/adapters/next/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +39 -22
- package/dist/adapters/node/index.d.ts +39 -22
- package/dist/adapters/node/index.mjs +74 -21
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +50 -36
- package/dist/index.d.ts +50 -36
- package/dist/index.mjs +27 -6
- 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.BqBN5WhH.d.mts → server.B77ImKAP.d.mts} +2 -2
- package/dist/shared/{server.CPqNKiJp.d.ts → server.BHlRCrf_.d.ts} +20 -29
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/server.Cud5qk0c.d.ts +10 -0
- package/dist/shared/{server.P4_D9lKb.d.mts → server.CzxlqYZL.d.mts} +20 -29
- package/dist/shared/server.DGnN7q3R.d.mts +10 -0
- package/dist/shared/{server.MZvbGc3n.d.mts → server.DLt5njUb.d.mts} +8 -8
- package/dist/shared/{server.MZvbGc3n.d.ts → server.DLt5njUb.d.ts} +8 -8
- package/dist/shared/{server.Dm3ZuTuI.d.ts → server.DUF89eb-.d.ts} +2 -2
- package/dist/shared/{server.BY9sDlwl.mjs → server.Dfx1jV-K.mjs} +30 -27
- package/dist/shared/server.T5WmDoWQ.mjs +98 -0
- package/dist/shared/{server.BtxZnWJ9.mjs → server.e3W6AG3-.mjs} +3 -7
- package/package.json +8 -8
- package/dist/shared/server.Dba3Iiyp.mjs +0 -12
- package/dist/shared/server.Del5OmaY.mjs +0 -29
package/README.md
CHANGED
@@ -53,6 +53,7 @@ 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).
|
58
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).
|
@@ -117,6 +118,14 @@ export const createPlanet = os
|
|
117
118
|
export const router = { planet: { list: listPlanet, find: findPlanet, create: createPlanet } }
|
118
119
|
```
|
119
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
|
+
|
120
129
|
## License
|
121
130
|
|
122
131
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
@@ -1,8 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.mjs';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.CzxlqYZL.mjs';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DGnN7q3R.mjs';
|
2
5
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import {
|
4
|
-
import { S as StandardHandleOptions } from '../../shared/server.P4_D9lKb.mjs';
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.BqBN5WhH.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.B77ImKAP.mjs';
|
6
7
|
import '@orpc/client';
|
7
8
|
import '@orpc/contract';
|
8
9
|
import '@orpc/standard-server';
|
@@ -15,14 +16,39 @@ type FetchHandleResult = {
|
|
15
16
|
matched: false;
|
16
17
|
response: undefined;
|
17
18
|
};
|
18
|
-
interface
|
19
|
-
|
19
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
20
21
|
}
|
21
|
-
|
22
|
-
|
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, ThrowableError>[];
|
28
|
+
plugins?: FetchHandlerPlugin<T>[];
|
29
|
+
}
|
30
|
+
declare class FetchHandler<T extends Context> {
|
23
31
|
private readonly standardHandler;
|
24
|
-
|
25
|
-
|
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>>);
|
26
52
|
}
|
27
53
|
|
28
|
-
export { type
|
54
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
@@ -1,8 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.js';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BHlRCrf_.js';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.Cud5qk0c.js';
|
2
5
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import {
|
4
|
-
import { S as StandardHandleOptions } from '../../shared/server.CPqNKiJp.js';
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.Dm3ZuTuI.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DUF89eb-.js';
|
6
7
|
import '@orpc/client';
|
7
8
|
import '@orpc/contract';
|
8
9
|
import '@orpc/standard-server';
|
@@ -15,14 +16,39 @@ type FetchHandleResult = {
|
|
15
16
|
matched: false;
|
16
17
|
response: undefined;
|
17
18
|
};
|
18
|
-
interface
|
19
|
-
|
19
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
20
21
|
}
|
21
|
-
|
22
|
-
|
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, ThrowableError>[];
|
28
|
+
plugins?: FetchHandlerPlugin<T>[];
|
29
|
+
}
|
30
|
+
declare class FetchHandler<T extends Context> {
|
23
31
|
private readonly standardHandler;
|
24
|
-
|
25
|
-
|
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>>);
|
26
52
|
}
|
27
53
|
|
28
|
-
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.BY9sDlwl.mjs';
|
1
|
+
export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.T5WmDoWQ.mjs';
|
5
2
|
import '@orpc/client';
|
3
|
+
import '@orpc/client/standard';
|
4
|
+
import '../../shared/server.Dfx1jV-K.mjs';
|
6
5
|
import '@orpc/shared';
|
7
|
-
import '../../shared/server.
|
8
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
6
|
+
import '../../shared/server.e3W6AG3-.mjs';
|
9
7
|
import '@orpc/contract';
|
8
|
+
import '@orpc/standard-server-fetch';
|
9
|
+
import '../../shared/server.BVwwTHyO.mjs';
|
@@ -1,11 +1,12 @@
|
|
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.DLt5njUb.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.CzxlqYZL.mjs';
|
7
|
+
import '../../shared/server.DGnN7q3R.mjs';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.B77ImKAP.mjs';
|
9
10
|
import '@orpc/client/standard';
|
10
11
|
import '@orpc/client';
|
11
12
|
import '@orpc/contract';
|
@@ -1,11 +1,12 @@
|
|
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.DLt5njUb.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.BHlRCrf_.js';
|
7
|
+
import '../../shared/server.Cud5qk0c.js';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DUF89eb-.js';
|
9
10
|
import '@orpc/client/standard';
|
10
11
|
import '@orpc/client';
|
11
12
|
import '@orpc/contract';
|
@@ -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.T5WmDoWQ.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
|
-
import '@orpc/client/standard';
|
4
|
-
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.BY9sDlwl.mjs';
|
6
3
|
import '@orpc/client';
|
7
|
-
import '
|
8
|
-
import '../../shared/server.
|
4
|
+
import '@orpc/client/standard';
|
5
|
+
import '../../shared/server.Dfx1jV-K.mjs';
|
6
|
+
import '../../shared/server.e3W6AG3-.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,11 +1,12 @@
|
|
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.DLt5njUb.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.CzxlqYZL.mjs';
|
7
|
+
import '../../shared/server.DGnN7q3R.mjs';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.B77ImKAP.mjs';
|
9
10
|
import '@orpc/client/standard';
|
10
11
|
import '@orpc/client';
|
11
12
|
import '@orpc/contract';
|
@@ -1,11 +1,12 @@
|
|
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.DLt5njUb.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.BHlRCrf_.js';
|
7
|
+
import '../../shared/server.Cud5qk0c.js';
|
7
8
|
import '@orpc/standard-server-fetch';
|
8
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DUF89eb-.js';
|
9
10
|
import '@orpc/client/standard';
|
10
11
|
import '@orpc/client';
|
11
12
|
import '@orpc/contract';
|
@@ -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.T5WmDoWQ.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
|
-
import '@orpc/client/standard';
|
4
|
-
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.BY9sDlwl.mjs';
|
6
3
|
import '@orpc/client';
|
7
|
-
import '
|
8
|
-
import '../../shared/server.
|
4
|
+
import '@orpc/client/standard';
|
5
|
+
import '../../shared/server.Dfx1jV-K.mjs';
|
6
|
+
import '../../shared/server.e3W6AG3-.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,36 +1,53 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.mjs';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
4
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.CzxlqYZL.mjs';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DGnN7q3R.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.B77ImKAP.mjs';
|
8
7
|
import '@orpc/client';
|
9
8
|
import '@orpc/contract';
|
10
9
|
import '@orpc/standard-server';
|
11
10
|
import '@orpc/client/standard';
|
12
11
|
|
13
|
-
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
14
|
-
/**
|
15
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
16
|
-
* This is useful for `express.js` middleware.
|
17
|
-
*/
|
18
|
-
originalUrl?: string;
|
19
|
-
};
|
20
|
-
type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
21
12
|
type NodeHttpHandleResult = {
|
22
13
|
matched: true;
|
23
14
|
} | {
|
24
15
|
matched: false;
|
25
16
|
};
|
26
|
-
interface
|
27
|
-
|
17
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
28
19
|
}
|
29
|
-
|
30
|
-
|
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, ThrowableError>[];
|
27
|
+
plugins?: NodeHttpHandlerPlugin<T>[];
|
28
|
+
}
|
29
|
+
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
31
30
|
private readonly standardHandler;
|
32
|
-
|
33
|
-
|
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>>);
|
34
51
|
}
|
35
52
|
|
36
|
-
export { type
|
53
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,36 +1,53 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.js';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
4
|
+
import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BHlRCrf_.js';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.Cud5qk0c.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DUF89eb-.js';
|
8
7
|
import '@orpc/client';
|
9
8
|
import '@orpc/contract';
|
10
9
|
import '@orpc/standard-server';
|
11
10
|
import '@orpc/client/standard';
|
12
11
|
|
13
|
-
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
14
|
-
/**
|
15
|
-
* Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
|
16
|
-
* This is useful for `express.js` middleware.
|
17
|
-
*/
|
18
|
-
originalUrl?: string;
|
19
|
-
};
|
20
|
-
type NodeHttpResponse = ServerResponse | Http2ServerResponse;
|
21
12
|
type NodeHttpHandleResult = {
|
22
13
|
matched: true;
|
23
14
|
} | {
|
24
15
|
matched: false;
|
25
16
|
};
|
26
|
-
interface
|
27
|
-
|
17
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
28
19
|
}
|
29
|
-
|
30
|
-
|
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, ThrowableError>[];
|
27
|
+
plugins?: NodeHttpHandlerPlugin<T>[];
|
28
|
+
}
|
29
|
+
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
31
30
|
private readonly standardHandler;
|
32
|
-
|
33
|
-
|
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>>);
|
34
51
|
}
|
35
52
|
|
36
|
-
export { type
|
53
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,32 +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.BtxZnWJ9.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.Dfx1jV-K.mjs';
|
7
|
+
import '../../shared/server.e3W6AG3-.mjs';
|
8
8
|
import '@orpc/contract';
|
9
9
|
|
10
|
-
class
|
11
|
-
|
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
|
+
});
|
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);
|
47
|
+
}
|
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 {
|
12
76
|
constructor(router, options = {}) {
|
13
77
|
const jsonSerializer = new StandardRPCJsonSerializer(options);
|
14
78
|
const serializer = new StandardRPCSerializer(jsonSerializer);
|
15
79
|
const matcher = new StandardRPCMatcher();
|
16
80
|
const codec = new StandardRPCCodec(serializer);
|
17
|
-
|
18
|
-
}
|
19
|
-
async handle(req, res, ...[
|
20
|
-
options = {}
|
21
|
-
]) {
|
22
|
-
const standardRequest = toStandardLazyRequest(req, res);
|
23
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
24
|
-
if (!result.matched) {
|
25
|
-
return { matched: false };
|
26
|
-
}
|
27
|
-
await sendStandardResponse(res, result.response, options);
|
28
|
-
return { matched: true };
|
81
|
+
super(new StandardHandler(router, matcher, codec, options), options);
|
29
82
|
}
|
30
83
|
}
|
31
84
|
|
32
|
-
export { RPCHandler };
|
85
|
+
export { BodyLimitPlugin, NodeHttpHandler, RPCHandler };
|
@@ -1,11 +1,11 @@
|
|
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.CzxlqYZL.mjs';
|
2
|
+
export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.CzxlqYZL.mjs';
|
3
|
+
import { ORPCError, HTTPPath } from '@orpc/client';
|
4
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
|
-
export { S as StandardRPCHandlerOptions } from '../../shared/server.
|
8
|
-
import
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.DLt5njUb.mjs';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.B77ImKAP.mjs';
|
8
|
+
import '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
11
11
|
declare class StandardRPCCodec implements StandardCodec {
|
@@ -1,11 +1,11 @@
|
|
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.BHlRCrf_.js';
|
2
|
+
export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.BHlRCrf_.js';
|
3
|
+
import { ORPCError, HTTPPath } from '@orpc/client';
|
4
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
|
-
export { S as StandardRPCHandlerOptions } from '../../shared/server.
|
8
|
-
import
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.DLt5njUb.js';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.DUF89eb-.js';
|
8
|
+
import '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
11
11
|
declare class StandardRPCCodec implements StandardCodec {
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.
|
1
|
+
export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.Dfx1jV-K.mjs';
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/shared';
|
4
|
-
import '../../shared/server.
|
5
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
4
|
+
import '../../shared/server.e3W6AG3-.mjs';
|
6
5
|
import '@orpc/contract';
|
6
|
+
import '@orpc/client/standard';
|