@orpc/server 0.51.0 → 0.53.0
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 +1 -0
- package/dist/adapters/fetch/index.d.mts +14 -10
- package/dist/adapters/fetch/index.d.ts +14 -10
- package/dist/adapters/fetch/index.mjs +6 -4
- package/dist/adapters/hono/index.d.mts +6 -6
- package/dist/adapters/hono/index.d.ts +6 -6
- package/dist/adapters/hono/index.mjs +10 -7
- package/dist/adapters/next/index.d.mts +6 -6
- package/dist/adapters/next/index.d.ts +6 -6
- package/dist/adapters/next/index.mjs +10 -7
- package/dist/adapters/node/index.d.mts +14 -10
- package/dist/adapters/node/index.d.ts +14 -10
- package/dist/adapters/node/index.mjs +17 -12
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +6 -3
- package/dist/index.d.mts +50 -36
- package/dist/index.d.ts +50 -36
- package/dist/index.mjs +32 -11
- package/dist/plugins/index.d.mts +100 -6
- package/dist/plugins/index.d.ts +100 -6
- package/dist/plugins/index.mjs +138 -1
- package/dist/shared/server.BW-nUGgA.mjs +36 -0
- package/dist/shared/{server.B4eSvRkD.mjs → server.Bm0UqHzd.mjs} +16 -11
- package/dist/shared/{server.BtxZnWJ9.mjs → server.C37gDhSZ.mjs} +19 -29
- package/dist/shared/server.C8NkqxHo.d.ts +17 -0
- package/dist/shared/{server.C-CCcROC.d.mts → server.CGCwEAt_.d.mts} +2 -2
- package/dist/shared/server.DCQgF_JR.d.mts +17 -0
- package/dist/shared/{server.23VRZIfj.d.ts → server.DFFT_EZo.d.ts} +18 -11
- package/dist/shared/{server.DnR6v9pj.mjs → server.DFuJLDuo.mjs} +43 -13
- 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.DJqfB27m.d.mts → server.DOYDVeMX.d.mts} +18 -11
- package/dist/shared/{server.BG5ftPWa.d.ts → server._2UufoXA.d.ts} +2 -2
- package/package.json +7 -7
- package/dist/shared/server.CIbpOMZX.d.mts +0 -8
- package/dist/shared/server.DCcCuA52.d.ts +0 -8
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).
|
@@ -1,14 +1,21 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.mjs';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { i as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, S as StandardHandleOptions, b as StandardHandler } from '../../shared/server.DOYDVeMX.mjs';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CGCwEAt_.mjs';
|
5
5
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DCQgF_JR.mjs';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
|
12
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
13
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
14
|
+
}
|
15
|
+
declare class CompositeFetchHandlerPlugin<T extends Context, TPlugin extends FetchHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements FetchHandlerPlugin<T> {
|
16
|
+
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
17
|
+
}
|
18
|
+
|
12
19
|
type FetchHandleResult = {
|
13
20
|
matched: true;
|
14
21
|
response: Response;
|
@@ -16,15 +23,12 @@ type FetchHandleResult = {
|
|
16
23
|
matched: false;
|
17
24
|
response: undefined;
|
18
25
|
};
|
19
|
-
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
-
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
21
|
-
}
|
22
26
|
interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
23
27
|
request: Request;
|
24
28
|
toFetchResponseOptions: ToFetchResponseOptions;
|
25
29
|
}
|
26
30
|
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
|
27
|
-
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult,
|
31
|
+
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, ThrowableError>[];
|
28
32
|
plugins?: FetchHandlerPlugin<T>[];
|
29
33
|
}
|
30
34
|
declare class FetchHandler<T extends Context> {
|
@@ -51,4 +55,4 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
51
55
|
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
52
56
|
}
|
53
57
|
|
54
|
-
export { BodyLimitPlugin, type BodyLimitPluginOptions, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
58
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, CompositeFetchHandlerPlugin, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
@@ -1,14 +1,21 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.js';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { i as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, S as StandardHandleOptions, b as StandardHandler } from '../../shared/server.DFFT_EZo.js';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server._2UufoXA.js';
|
5
5
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.C8NkqxHo.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
|
12
|
+
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
13
|
+
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
14
|
+
}
|
15
|
+
declare class CompositeFetchHandlerPlugin<T extends Context, TPlugin extends FetchHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements FetchHandlerPlugin<T> {
|
16
|
+
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
17
|
+
}
|
18
|
+
|
12
19
|
type FetchHandleResult = {
|
13
20
|
matched: true;
|
14
21
|
response: Response;
|
@@ -16,15 +23,12 @@ type FetchHandleResult = {
|
|
16
23
|
matched: false;
|
17
24
|
response: undefined;
|
18
25
|
};
|
19
|
-
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
20
|
-
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
21
|
-
}
|
22
26
|
interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
23
27
|
request: Request;
|
24
28
|
toFetchResponseOptions: ToFetchResponseOptions;
|
25
29
|
}
|
26
30
|
interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
|
27
|
-
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult,
|
31
|
+
adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, ThrowableError>[];
|
28
32
|
plugins?: FetchHandlerPlugin<T>[];
|
29
33
|
}
|
30
34
|
declare class FetchHandler<T extends Context> {
|
@@ -51,4 +55,4 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
51
55
|
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
52
56
|
}
|
53
57
|
|
54
|
-
export { BodyLimitPlugin, type BodyLimitPluginOptions, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
58
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, CompositeFetchHandlerPlugin, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
|
@@ -1,9 +1,11 @@
|
|
1
|
-
export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.
|
1
|
+
export { B as BodyLimitPlugin, C as CompositeFetchHandlerPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Bm0UqHzd.mjs';
|
2
2
|
import '@orpc/client';
|
3
|
-
import '@orpc/client/standard';
|
4
|
-
import '../../shared/server.DnR6v9pj.mjs';
|
5
3
|
import '@orpc/shared';
|
6
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
7
4
|
import '@orpc/contract';
|
5
|
+
import '../../shared/server.DFuJLDuo.mjs';
|
6
|
+
import '@orpc/client/standard';
|
7
|
+
import '@orpc/standard-server/batch';
|
8
|
+
import '../../shared/server.BW-nUGgA.mjs';
|
9
|
+
import '../../shared/server.C37gDhSZ.mjs';
|
8
10
|
import '@orpc/standard-server-fetch';
|
9
11
|
import '../../shared/server.BVwwTHyO.mjs';
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.mjs';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
|
2
|
+
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, 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.
|
7
|
-
import '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.DLt5njUb.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DOYDVeMX.mjs';
|
7
|
+
import '../../shared/server.CGCwEAt_.mjs';
|
8
8
|
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DCQgF_JR.mjs';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
import '@orpc/client';
|
12
12
|
import '@orpc/contract';
|
@@ -17,6 +17,6 @@ type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>,
|
|
17
17
|
} : {
|
18
18
|
context: Value<T, [Context$1]>;
|
19
19
|
});
|
20
|
-
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...
|
20
|
+
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
21
21
|
|
22
22
|
export { type CreateMiddlewareOptions, FetchHandler, createMiddleware };
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.js';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
|
2
|
+
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, 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.
|
7
|
-
import '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.DLt5njUb.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DFFT_EZo.js';
|
7
|
+
import '../../shared/server._2UufoXA.js';
|
8
8
|
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.C8NkqxHo.js';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
import '@orpc/client';
|
12
12
|
import '@orpc/contract';
|
@@ -17,6 +17,6 @@ type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>,
|
|
17
17
|
} : {
|
18
18
|
context: Value<T, [Context$1]>;
|
19
19
|
});
|
20
|
-
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...
|
20
|
+
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
21
21
|
|
22
22
|
export { type CreateMiddlewareOptions, FetchHandler, createMiddleware };
|
@@ -1,14 +1,17 @@
|
|
1
|
-
export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.
|
2
|
-
import { value } from '@orpc/shared';
|
1
|
+
export { B as BodyLimitPlugin, C as CompositeFetchHandlerPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Bm0UqHzd.mjs';
|
2
|
+
import { resolveMaybeOptionalOptions, value } from '@orpc/shared';
|
3
3
|
import '@orpc/client';
|
4
|
-
import '@orpc/client/standard';
|
5
|
-
import '../../shared/server.DnR6v9pj.mjs';
|
6
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
7
4
|
import '@orpc/contract';
|
5
|
+
import '../../shared/server.DFuJLDuo.mjs';
|
6
|
+
import '@orpc/client/standard';
|
7
|
+
import '@orpc/standard-server/batch';
|
8
|
+
import '../../shared/server.BW-nUGgA.mjs';
|
9
|
+
import '../../shared/server.C37gDhSZ.mjs';
|
8
10
|
import '@orpc/standard-server-fetch';
|
9
11
|
import '../../shared/server.BVwwTHyO.mjs';
|
10
12
|
|
11
|
-
function createMiddleware(handler, ...
|
13
|
+
function createMiddleware(handler, ...rest) {
|
14
|
+
const options = resolveMaybeOptionalOptions(rest);
|
12
15
|
return async (c, next) => {
|
13
16
|
const bodyProps = /* @__PURE__ */ new Set(["arrayBuffer", "blob", "formData", "json", "text"]);
|
14
17
|
const request = c.req.method === "GET" || c.req.method === "HEAD" ? c.req.raw : new Proxy(c.req.raw, {
|
@@ -20,7 +23,7 @@ function createMiddleware(handler, ...[options]) {
|
|
20
23
|
return Reflect.get(target, prop, target);
|
21
24
|
}
|
22
25
|
});
|
23
|
-
const context = await value(options
|
26
|
+
const context = await value(options.context ?? {}, c);
|
24
27
|
const { matched, response } = await handler.handle(request, { ...options, context });
|
25
28
|
if (matched) {
|
26
29
|
return c.newResponse(response.body, response);
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.mjs';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
|
2
|
+
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, 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.
|
7
|
-
import '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.DLt5njUb.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DOYDVeMX.mjs';
|
7
|
+
import '../../shared/server.CGCwEAt_.mjs';
|
8
8
|
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DCQgF_JR.mjs';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
import '@orpc/client';
|
12
12
|
import '@orpc/contract';
|
@@ -24,6 +24,6 @@ interface ServeResult {
|
|
24
24
|
PATCH(req: NextRequest): Promise<Response>;
|
25
25
|
DELETE(req: NextRequest): Promise<Response>;
|
26
26
|
}
|
27
|
-
declare function serve<T extends Context>(handler: FetchHandler<T>, ...
|
27
|
+
declare function serve<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
28
28
|
|
29
29
|
export { FetchHandler, type ServeOptions, type ServeResult, serve };
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { FetchHandler } from '../fetch/index.js';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
|
2
|
+
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, 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.
|
7
|
-
import '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.DLt5njUb.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.DFFT_EZo.js';
|
7
|
+
import '../../shared/server._2UufoXA.js';
|
8
8
|
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.C8NkqxHo.js';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
import '@orpc/client';
|
12
12
|
import '@orpc/contract';
|
@@ -24,6 +24,6 @@ interface ServeResult {
|
|
24
24
|
PATCH(req: NextRequest): Promise<Response>;
|
25
25
|
DELETE(req: NextRequest): Promise<Response>;
|
26
26
|
}
|
27
|
-
declare function serve<T extends Context>(handler: FetchHandler<T>, ...
|
27
|
+
declare function serve<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
28
28
|
|
29
29
|
export { FetchHandler, type ServeOptions, type ServeResult, serve };
|
@@ -1,16 +1,19 @@
|
|
1
|
-
export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.
|
2
|
-
import { value } from '@orpc/shared';
|
1
|
+
export { B as BodyLimitPlugin, C as CompositeFetchHandlerPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.Bm0UqHzd.mjs';
|
2
|
+
import { resolveMaybeOptionalOptions, value } from '@orpc/shared';
|
3
3
|
import '@orpc/client';
|
4
|
-
import '@orpc/client/standard';
|
5
|
-
import '../../shared/server.DnR6v9pj.mjs';
|
6
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
7
4
|
import '@orpc/contract';
|
5
|
+
import '../../shared/server.DFuJLDuo.mjs';
|
6
|
+
import '@orpc/client/standard';
|
7
|
+
import '@orpc/standard-server/batch';
|
8
|
+
import '../../shared/server.BW-nUGgA.mjs';
|
9
|
+
import '../../shared/server.C37gDhSZ.mjs';
|
8
10
|
import '@orpc/standard-server-fetch';
|
9
11
|
import '../../shared/server.BVwwTHyO.mjs';
|
10
12
|
|
11
|
-
function serve(handler, ...
|
13
|
+
function serve(handler, ...rest) {
|
14
|
+
const options = resolveMaybeOptionalOptions(rest);
|
12
15
|
const main = async (req) => {
|
13
|
-
const context = await value(options
|
16
|
+
const context = await value(options.context ?? {}, req);
|
14
17
|
const { matched, response } = await handler.handle(req, { ...options, context });
|
15
18
|
if (matched) {
|
16
19
|
return response;
|
@@ -1,29 +1,33 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.mjs';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
|
4
|
+
import { i as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, S as StandardHandleOptions, b as StandardHandler } from '../../shared/server.DOYDVeMX.mjs';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CGCwEAt_.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DCQgF_JR.mjs';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
|
12
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
13
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
14
|
+
}
|
15
|
+
declare class CompositeNodeHttpHandlerPlugin<T extends Context, TPlugin extends NodeHttpHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements NodeHttpHandlerPlugin<T> {
|
16
|
+
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
17
|
+
}
|
18
|
+
|
12
19
|
type NodeHttpHandleResult = {
|
13
20
|
matched: true;
|
14
21
|
} | {
|
15
22
|
matched: false;
|
16
23
|
};
|
17
|
-
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
-
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
19
|
-
}
|
20
24
|
interface NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
21
25
|
request: NodeHttpRequest;
|
22
26
|
response: NodeHttpResponse;
|
23
27
|
sendStandardResponseOptions: SendStandardResponseOptions;
|
24
28
|
}
|
25
29
|
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
26
|
-
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, NodeHttpHandleResult,
|
30
|
+
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, NodeHttpHandleResult, ThrowableError>[];
|
27
31
|
plugins?: NodeHttpHandlerPlugin<T>[];
|
28
32
|
}
|
29
33
|
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
@@ -50,4 +54,4 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
50
54
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
51
55
|
}
|
52
56
|
|
53
|
-
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
57
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, CompositeNodeHttpHandlerPlugin, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -1,29 +1,33 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.DLt5njUb.js';
|
2
|
+
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
|
4
|
+
import { i as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, S as StandardHandleOptions, b as StandardHandler } from '../../shared/server.DFFT_EZo.js';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server._2UufoXA.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.C8NkqxHo.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
10
|
import '@orpc/client/standard';
|
11
11
|
|
12
|
+
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
13
|
+
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
14
|
+
}
|
15
|
+
declare class CompositeNodeHttpHandlerPlugin<T extends Context, TPlugin extends NodeHttpHandlerPlugin<T>> extends CompositeStandardHandlerPlugin<T, TPlugin> implements NodeHttpHandlerPlugin<T> {
|
16
|
+
initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
|
17
|
+
}
|
18
|
+
|
12
19
|
type NodeHttpHandleResult = {
|
13
20
|
matched: true;
|
14
21
|
} | {
|
15
22
|
matched: false;
|
16
23
|
};
|
17
|
-
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
18
|
-
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
19
|
-
}
|
20
24
|
interface NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
21
25
|
request: NodeHttpRequest;
|
22
26
|
response: NodeHttpResponse;
|
23
27
|
sendStandardResponseOptions: SendStandardResponseOptions;
|
24
28
|
}
|
25
29
|
interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
26
|
-
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, NodeHttpHandleResult,
|
30
|
+
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, NodeHttpHandleResult, ThrowableError>[];
|
27
31
|
plugins?: NodeHttpHandlerPlugin<T>[];
|
28
32
|
}
|
29
33
|
declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
|
@@ -50,4 +54,4 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
50
54
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
51
55
|
}
|
52
56
|
|
53
|
-
export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
57
|
+
export { BodyLimitPlugin, type BodyLimitPluginOptions, CompositeNodeHttpHandlerPlugin, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
|
@@ -2,10 +2,12 @@ import { ORPCError } from '@orpc/client';
|
|
2
2
|
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
4
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.DnR6v9pj.mjs';
|
7
|
-
import '../../shared/server.BtxZnWJ9.mjs';
|
8
5
|
import '@orpc/contract';
|
6
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.DFuJLDuo.mjs';
|
7
|
+
import '@orpc/client/standard';
|
8
|
+
import '@orpc/standard-server/batch';
|
9
|
+
import '../../shared/server.BW-nUGgA.mjs';
|
10
|
+
import '../../shared/server.C37gDhSZ.mjs';
|
9
11
|
|
10
12
|
class BodyLimitPlugin {
|
11
13
|
maxBodySize;
|
@@ -39,12 +41,19 @@ class BodyLimitPlugin {
|
|
39
41
|
}
|
40
42
|
}
|
41
43
|
|
44
|
+
class CompositeNodeHttpHandlerPlugin extends CompositeStandardHandlerPlugin {
|
45
|
+
initRuntimeAdapter(options) {
|
46
|
+
for (const plugin of this.plugins) {
|
47
|
+
plugin.initRuntimeAdapter?.(options);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
42
52
|
class NodeHttpHandler {
|
43
53
|
constructor(standardHandler, options = {}) {
|
44
54
|
this.standardHandler = standardHandler;
|
45
|
-
|
46
|
-
|
47
|
-
}
|
55
|
+
const plugin = new CompositeNodeHttpHandlerPlugin(options.plugins);
|
56
|
+
plugin.initRuntimeAdapter(options);
|
48
57
|
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
49
58
|
this.sendStandardResponseOptions = options;
|
50
59
|
}
|
@@ -74,12 +83,8 @@ class NodeHttpHandler {
|
|
74
83
|
|
75
84
|
class RPCHandler extends NodeHttpHandler {
|
76
85
|
constructor(router, options = {}) {
|
77
|
-
|
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);
|
86
|
+
super(new StandardRPCHandler(router, options), options);
|
82
87
|
}
|
83
88
|
}
|
84
89
|
|
85
|
-
export { BodyLimitPlugin, NodeHttpHandler, RPCHandler };
|
90
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
export { S as StandardHandleOptions,
|
3
|
-
import { ORPCError } from '@orpc/client';
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.DOYDVeMX.mjs';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandleOptions, g as StandardHandleResult, b as StandardHandler, h as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, i as StandardHandlerPlugin } from '../../shared/server.DOYDVeMX.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 { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.DCQgF_JR.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 { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.DFFT_EZo.js';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandleOptions, g as StandardHandleResult, b as StandardHandler, h as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, i as StandardHandlerPlugin } from '../../shared/server.DFFT_EZo.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 { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.C8NkqxHo.js';
|
8
|
+
import '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
11
11
|
declare class StandardRPCCodec implements StandardCodec {
|
@@ -1,5 +1,8 @@
|
|
1
|
-
export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.
|
2
|
-
import '@orpc/client';
|
1
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.DFuJLDuo.mjs';
|
2
|
+
import '@orpc/client/standard';
|
3
3
|
import '@orpc/shared';
|
4
|
-
import '
|
4
|
+
import '@orpc/standard-server/batch';
|
5
|
+
import '@orpc/client';
|
6
|
+
import '../../shared/server.BW-nUGgA.mjs';
|
5
7
|
import '@orpc/contract';
|
8
|
+
import '../../shared/server.C37gDhSZ.mjs';
|