@orpc/server 1.0.0-beta.6 → 1.0.0-beta.7
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/dist/adapters/fetch/index.d.mts +6 -5
- package/dist/adapters/fetch/index.d.ts +6 -5
- package/dist/adapters/fetch/index.mjs +100 -6
- package/dist/adapters/node/index.d.mts +6 -5
- package/dist/adapters/node/index.d.ts +6 -5
- package/dist/adapters/standard/index.d.mts +4 -4
- package/dist/adapters/standard/index.d.ts +4 -4
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/plugins/index.d.mts +4 -3
- package/dist/plugins/index.d.ts +4 -3
- package/dist/plugins/index.mjs +9 -1
- package/dist/shared/{server.DFFT_EZo.d.ts → server.B1oIHH_j.d.mts} +13 -12
- package/dist/shared/{server.DLt5njUb.d.mts → server.BVHsfJ99.d.mts} +3 -2
- package/dist/shared/{server.DLt5njUb.d.ts → server.BVHsfJ99.d.ts} +3 -2
- package/dist/shared/{server.DCQgF_JR.d.mts → server.BuLPHTX1.d.mts} +4 -3
- package/dist/shared/{server.DOYDVeMX.d.mts → server.CaWivVk3.d.ts} +13 -12
- package/dist/shared/{server._2UufoXA.d.ts → server.DMhSfHk1.d.ts} +2 -2
- package/dist/shared/{server.C8NkqxHo.d.ts → server.D_vpYits.d.ts} +4 -3
- package/dist/shared/{server.CGCwEAt_.d.mts → server.Dwnm6cSk.d.mts} +2 -2
- package/package.json +8 -22
- package/dist/adapters/hono/index.d.mts +0 -22
- package/dist/adapters/hono/index.d.ts +0 -22
- package/dist/adapters/hono/index.mjs +0 -35
- package/dist/adapters/next/index.d.mts +0 -29
- package/dist/adapters/next/index.d.ts +0 -29
- package/dist/adapters/next/index.mjs +0 -32
- package/dist/shared/server.Bm0UqHzd.mjs +0 -103
@@ -1,9 +1,9 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.BVHsfJ99.mjs';
|
2
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
3
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
6
|
-
import {
|
4
|
+
import { a as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, g as StandardHandleOptions, i as StandardHandler } from '../../shared/server.B1oIHH_j.mjs';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.Dwnm6cSk.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BuLPHTX1.mjs';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
@@ -55,4 +55,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
55
55
|
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
56
56
|
}
|
57
57
|
|
58
|
-
export { BodyLimitPlugin,
|
58
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
59
|
+
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin };
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.BVHsfJ99.js';
|
2
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
3
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
6
|
-
import {
|
4
|
+
import { a as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, g as StandardHandleOptions, i as StandardHandler } from '../../shared/server.CaWivVk3.js';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DMhSfHk1.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.D_vpYits.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
@@ -55,4 +55,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
55
55
|
constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
|
56
56
|
}
|
57
57
|
|
58
|
-
export { BodyLimitPlugin,
|
58
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
59
|
+
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin };
|
@@ -1,11 +1,105 @@
|
|
1
|
-
|
2
|
-
import '@orpc/
|
3
|
-
import '@orpc/
|
1
|
+
import { ORPCError } from '@orpc/client';
|
2
|
+
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
4
|
+
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.BVwwTHyO.mjs';
|
4
5
|
import '@orpc/contract';
|
5
|
-
import '../../shared/server.DFuJLDuo.mjs';
|
6
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.DFuJLDuo.mjs';
|
6
7
|
import '@orpc/client/standard';
|
7
8
|
import '@orpc/standard-server/batch';
|
8
9
|
import '../../shared/server.BW-nUGgA.mjs';
|
9
10
|
import '../../shared/server.C37gDhSZ.mjs';
|
10
|
-
|
11
|
-
|
11
|
+
|
12
|
+
class BodyLimitPlugin {
|
13
|
+
maxBodySize;
|
14
|
+
constructor(options) {
|
15
|
+
this.maxBodySize = options.maxBodySize;
|
16
|
+
}
|
17
|
+
initRuntimeAdapter(options) {
|
18
|
+
options.adapterInterceptors ??= [];
|
19
|
+
options.adapterInterceptors.push(async (options2) => {
|
20
|
+
if (!options2.request.body) {
|
21
|
+
return options2.next();
|
22
|
+
}
|
23
|
+
let currentBodySize = 0;
|
24
|
+
const rawReader = options2.request.body.getReader();
|
25
|
+
const reader = new ReadableStream({
|
26
|
+
start: async (controller) => {
|
27
|
+
try {
|
28
|
+
if (Number(options2.request.headers.get("content-length")) > this.maxBodySize) {
|
29
|
+
controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
while (true) {
|
33
|
+
const { done, value } = await rawReader.read();
|
34
|
+
if (done) {
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
currentBodySize += value.length;
|
38
|
+
if (currentBodySize > this.maxBodySize) {
|
39
|
+
controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
controller.enqueue(value);
|
43
|
+
}
|
44
|
+
} finally {
|
45
|
+
controller.close();
|
46
|
+
}
|
47
|
+
}
|
48
|
+
});
|
49
|
+
const requestInit = { body: reader, duplex: "half" };
|
50
|
+
return options2.next({
|
51
|
+
...options2,
|
52
|
+
request: new Request(options2.request, requestInit)
|
53
|
+
});
|
54
|
+
});
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
class CompositeFetchHandlerPlugin extends CompositeStandardHandlerPlugin {
|
59
|
+
initRuntimeAdapter(options) {
|
60
|
+
for (const plugin of this.plugins) {
|
61
|
+
plugin.initRuntimeAdapter?.(options);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
class FetchHandler {
|
67
|
+
constructor(standardHandler, options = {}) {
|
68
|
+
this.standardHandler = standardHandler;
|
69
|
+
const plugin = new CompositeFetchHandlerPlugin(options.plugins);
|
70
|
+
plugin.initRuntimeAdapter(options);
|
71
|
+
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
72
|
+
this.toFetchResponseOptions = options;
|
73
|
+
}
|
74
|
+
toFetchResponseOptions;
|
75
|
+
adapterInterceptors;
|
76
|
+
async handle(request, ...rest) {
|
77
|
+
return intercept(
|
78
|
+
this.adapterInterceptors,
|
79
|
+
{
|
80
|
+
...resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest)),
|
81
|
+
request,
|
82
|
+
toFetchResponseOptions: this.toFetchResponseOptions
|
83
|
+
},
|
84
|
+
async ({ request: request2, toFetchResponseOptions, ...options }) => {
|
85
|
+
const standardRequest = toStandardLazyRequest(request2);
|
86
|
+
const result = await this.standardHandler.handle(standardRequest, options);
|
87
|
+
if (!result.matched) {
|
88
|
+
return result;
|
89
|
+
}
|
90
|
+
return {
|
91
|
+
matched: true,
|
92
|
+
response: toFetchResponse(result.response, toFetchResponseOptions)
|
93
|
+
};
|
94
|
+
}
|
95
|
+
);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
class RPCHandler extends FetchHandler {
|
100
|
+
constructor(router, options = {}) {
|
101
|
+
super(new StandardRPCHandler(router, options), options);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.BVHsfJ99.mjs';
|
2
2
|
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
4
|
-
import {
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
4
|
+
import { a as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, g as StandardHandleOptions, i as StandardHandler } from '../../shared/server.B1oIHH_j.mjs';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.Dwnm6cSk.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BuLPHTX1.mjs';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
@@ -54,4 +54,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
54
54
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
55
55
|
}
|
56
56
|
|
57
|
-
export { BodyLimitPlugin,
|
57
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
58
|
+
export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin };
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.BVHsfJ99.js';
|
2
2
|
import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
4
|
-
import {
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
4
|
+
import { a as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, g as StandardHandleOptions, i as StandardHandler } from '../../shared/server.CaWivVk3.js';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DMhSfHk1.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.D_vpYits.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
@@ -54,4 +54,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
54
54
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
|
55
55
|
}
|
56
56
|
|
57
|
-
export { BodyLimitPlugin,
|
57
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
58
|
+
export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin };
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { C as CompositeStandardHandlerPlugin,
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.B1oIHH_j.mjs';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, g as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.B1oIHH_j.mjs';
|
3
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 {
|
7
|
-
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { h as AnyProcedure, f as AnyRouter } from '../../shared/server.BVHsfJ99.mjs';
|
7
|
+
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.BuLPHTX1.mjs';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { C as CompositeStandardHandlerPlugin,
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.CaWivVk3.js';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, g as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, S as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, a as StandardHandlerPlugin } from '../../shared/server.CaWivVk3.js';
|
3
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 {
|
7
|
-
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { h as AnyProcedure, f as AnyRouter } from '../../shared/server.BVHsfJ99.js';
|
7
|
+
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.D_vpYits.js';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
package/dist/index.d.mts
CHANGED
@@ -4,8 +4,8 @@ import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErro
|
|
4
4
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
5
5
|
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
6
6
|
export { IntersectPick, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
|
-
import { C as Context,
|
8
|
-
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs,
|
7
|
+
import { C as Context, P as Procedure, M as Middleware, O as ORPCErrorConstructorMap, a as MergedInitialContext, b as MergedCurrentContext, c as MapInputMiddleware, d as CreateProcedureClientOptions, e as ProcedureClient, A as AnyMiddleware, L as Lazyable, f as AnyRouter, g as Lazy, h as AnyProcedure, i as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.BVHsfJ99.mjs';
|
8
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, w as MiddlewareNextFn, t as MiddlewareNextFnOptions, y as MiddlewareOptions, x as MiddlewareOutputFn, s as MiddlewareResult, k as ORPCErrorConstructorMapItem, j as ORPCErrorConstructorMapItemOptions, F as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, l as createORPCErrorConstructorMap, G as createProcedureClient, r as getLazyMeta, q as isLazy, E as isProcedure, p as lazy, m as mergeCurrentContext, z as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.BVHsfJ99.mjs';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
11
|
type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
|
@@ -288,4 +288,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
288
288
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
289
289
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
290
290
|
|
291
|
-
export {
|
291
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createAccessibleLazyRouter, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|
292
|
+
export type { AccessibleLazyRouter, ActionableClient, ActionableClientRest, ActionableClientResult, ActionableError, BuilderConfig, BuilderDef, BuilderWithMiddlewares, Config, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureActionableClient, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithInputOutput, ProcedureBuilderWithOutput, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProceduresOptions, UnactionableError, UnlaziedRouter };
|
package/dist/index.d.ts
CHANGED
@@ -4,8 +4,8 @@ import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErro
|
|
4
4
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
5
5
|
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
6
6
|
export { IntersectPick, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
|
-
import { C as Context,
|
8
|
-
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs,
|
7
|
+
import { C as Context, P as Procedure, M as Middleware, O as ORPCErrorConstructorMap, a as MergedInitialContext, b as MergedCurrentContext, c as MapInputMiddleware, d as CreateProcedureClientOptions, e as ProcedureClient, A as AnyMiddleware, L as Lazyable, f as AnyRouter, g as Lazy, h as AnyProcedure, i as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.BVHsfJ99.js';
|
8
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, w as MiddlewareNextFn, t as MiddlewareNextFnOptions, y as MiddlewareOptions, x as MiddlewareOutputFn, s as MiddlewareResult, k as ORPCErrorConstructorMapItem, j as ORPCErrorConstructorMapItemOptions, F as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, l as createORPCErrorConstructorMap, G as createProcedureClient, r as getLazyMeta, q as isLazy, E as isProcedure, p as lazy, m as mergeCurrentContext, z as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.BVHsfJ99.js';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
11
|
type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
|
@@ -288,4 +288,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
288
288
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
289
289
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
290
290
|
|
291
|
-
export {
|
291
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createAccessibleLazyRouter, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|
292
|
+
export type { AccessibleLazyRouter, ActionableClient, ActionableClientRest, ActionableClientResult, ActionableError, BuilderConfig, BuilderDef, BuilderWithMiddlewares, Config, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureActionableClient, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithInputOutput, ProcedureBuilderWithOutput, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProceduresOptions, UnactionableError, UnlaziedRouter };
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Value } from '@orpc/shared';
|
2
2
|
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
3
|
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
4
|
-
import {
|
5
|
-
import { C as Context,
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.B1oIHH_j.mjs';
|
5
|
+
import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.BVHsfJ99.mjs';
|
6
6
|
import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
|
7
7
|
import { ORPCError } from '@orpc/client';
|
8
8
|
|
@@ -121,4 +121,5 @@ declare class StrictGetMethodPlugin<T extends Context> implements StandardHandle
|
|
121
121
|
init(options: StandardHandlerOptions<T>): void;
|
122
122
|
}
|
123
123
|
|
124
|
-
export {
|
124
|
+
export { BatchHandlerPlugin, CORSPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
|
125
|
+
export type { BatchHandlerOptions, CORSOptions, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Value } from '@orpc/shared';
|
2
2
|
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
3
|
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
4
|
-
import {
|
5
|
-
import { C as Context,
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CaWivVk3.js';
|
5
|
+
import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.BVHsfJ99.js';
|
6
6
|
import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
|
7
7
|
import { ORPCError } from '@orpc/client';
|
8
8
|
|
@@ -121,4 +121,5 @@ declare class StrictGetMethodPlugin<T extends Context> implements StandardHandle
|
|
121
121
|
init(options: StandardHandlerOptions<T>): void;
|
122
122
|
}
|
123
123
|
|
124
|
-
export {
|
124
|
+
export { BatchHandlerPlugin, CORSPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
|
125
|
+
export type { BatchHandlerOptions, CORSOptions, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions };
|
package/dist/plugins/index.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { value } from '@orpc/shared';
|
1
|
+
import { value, isAsyncIteratorObject } from '@orpc/shared';
|
2
2
|
import { parseBatchRequest, toBatchResponse } from '@orpc/standard-server/batch';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
4
|
export { S as StrictGetMethodPlugin } from '../shared/server.BW-nUGgA.mjs';
|
@@ -49,6 +49,14 @@ class BatchHandlerPlugin {
|
|
49
49
|
const mapped = this.mapRequestItem(request, options2);
|
50
50
|
return options2.next({ ...options2, request: { ...mapped, body: () => Promise.resolve(mapped.body) } }).then(({ response: response2, matched }) => {
|
51
51
|
if (matched) {
|
52
|
+
if (response2.body instanceof Blob || response2.body instanceof FormData || isAsyncIteratorObject(response2.body)) {
|
53
|
+
return {
|
54
|
+
index,
|
55
|
+
status: 500,
|
56
|
+
headers: {},
|
57
|
+
body: "Batch responses do not support file/blob, or event-iterator. Please call this procedure separately outside of the batch request."
|
58
|
+
};
|
59
|
+
}
|
52
60
|
return { ...response2, index };
|
53
61
|
}
|
54
62
|
return { index, status: 404, headers: {}, body: "No procedure matched" };
|
@@ -2,7 +2,17 @@ import { HTTPPath, ORPCError } from '@orpc/client';
|
|
2
2
|
import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
|
3
3
|
import { Interceptor, ThrowableError } from '@orpc/shared';
|
4
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
5
|
-
import {
|
5
|
+
import { C as Context, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions, R as Router } from './server.BVHsfJ99.mjs';
|
6
|
+
|
7
|
+
interface StandardHandlerPlugin<TContext extends Context> {
|
8
|
+
order?: number;
|
9
|
+
init?(options: StandardHandlerOptions<TContext>): void;
|
10
|
+
}
|
11
|
+
declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
|
12
|
+
protected readonly plugins: TPlugin[];
|
13
|
+
constructor(plugins?: readonly TPlugin[]);
|
14
|
+
init(options: StandardHandlerOptions<T>): void;
|
15
|
+
}
|
6
16
|
|
7
17
|
type StandardParams = Record<string, string>;
|
8
18
|
type StandardMatchResult = {
|
@@ -20,16 +30,6 @@ interface StandardCodec {
|
|
20
30
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
21
31
|
}
|
22
32
|
|
23
|
-
interface StandardHandlerPlugin<TContext extends Context> {
|
24
|
-
order?: number;
|
25
|
-
init?(options: StandardHandlerOptions<TContext>): void;
|
26
|
-
}
|
27
|
-
declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
|
28
|
-
protected readonly plugins: TPlugin[];
|
29
|
-
constructor(plugins?: readonly TPlugin[]);
|
30
|
-
init(options: StandardHandlerOptions<T>): void;
|
31
|
-
}
|
32
|
-
|
33
33
|
interface StandardHandleOptions<T extends Context> {
|
34
34
|
prefix?: HTTPPath;
|
35
35
|
context: T;
|
@@ -70,4 +70,5 @@ declare class StandardHandler<T extends Context> {
|
|
70
70
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
71
71
|
}
|
72
72
|
|
73
|
-
export { CompositeStandardHandlerPlugin as C,
|
73
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as i };
|
74
|
+
export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardCodec as c, StandardParams as d, StandardMatcher as e, StandardMatchResult as f, StandardHandleOptions as g, StandardHandleResult as h };
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
|
2
|
-
import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
3
2
|
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
3
|
+
import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
4
4
|
|
5
5
|
type Context = Record<PropertyKey, any>;
|
6
6
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
@@ -140,4 +140,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
140
140
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
141
141
|
};
|
142
142
|
|
143
|
-
export {
|
143
|
+
export { isProcedure as E, createProcedureClient as G, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, validateORPCError as v, middlewareOutputFn as z };
|
144
|
+
export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, ProcedureClientInterceptorOptions as F, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
|
2
|
-
import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
3
2
|
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
3
|
+
import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
4
4
|
|
5
5
|
type Context = Record<PropertyKey, any>;
|
6
6
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
@@ -140,4 +140,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
140
140
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
141
141
|
};
|
142
142
|
|
143
|
-
export {
|
143
|
+
export { isProcedure as E, createProcedureClient as G, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, validateORPCError as v, middlewareOutputFn as z };
|
144
|
+
export type { AnyMiddleware as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, ProcedureClientInterceptorOptions as F, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { C as Context, R as Router } from './server.DLt5njUb.mjs';
|
2
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
3
|
-
import {
|
2
|
+
import { C as Context, R as Router } from './server.BVHsfJ99.mjs';
|
3
|
+
import { b as StandardHandlerOptions, i as StandardHandler } from './server.B1oIHH_j.mjs';
|
4
4
|
|
5
5
|
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
6
|
/**
|
@@ -14,4 +14,5 @@ declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
|
|
14
14
|
constructor(router: Router<any, T>, options: StandardRPCHandlerOptions<T>);
|
15
15
|
}
|
16
16
|
|
17
|
-
export {
|
17
|
+
export { StandardRPCHandler as a };
|
18
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -2,7 +2,17 @@ import { HTTPPath, ORPCError } from '@orpc/client';
|
|
2
2
|
import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
|
3
3
|
import { Interceptor, ThrowableError } from '@orpc/shared';
|
4
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
5
|
-
import {
|
5
|
+
import { C as Context, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions, R as Router } from './server.BVHsfJ99.js';
|
6
|
+
|
7
|
+
interface StandardHandlerPlugin<TContext extends Context> {
|
8
|
+
order?: number;
|
9
|
+
init?(options: StandardHandlerOptions<TContext>): void;
|
10
|
+
}
|
11
|
+
declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
|
12
|
+
protected readonly plugins: TPlugin[];
|
13
|
+
constructor(plugins?: readonly TPlugin[]);
|
14
|
+
init(options: StandardHandlerOptions<T>): void;
|
15
|
+
}
|
6
16
|
|
7
17
|
type StandardParams = Record<string, string>;
|
8
18
|
type StandardMatchResult = {
|
@@ -20,16 +30,6 @@ interface StandardCodec {
|
|
20
30
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
21
31
|
}
|
22
32
|
|
23
|
-
interface StandardHandlerPlugin<TContext extends Context> {
|
24
|
-
order?: number;
|
25
|
-
init?(options: StandardHandlerOptions<TContext>): void;
|
26
|
-
}
|
27
|
-
declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
|
28
|
-
protected readonly plugins: TPlugin[];
|
29
|
-
constructor(plugins?: readonly TPlugin[]);
|
30
|
-
init(options: StandardHandlerOptions<T>): void;
|
31
|
-
}
|
32
|
-
|
33
33
|
interface StandardHandleOptions<T extends Context> {
|
34
34
|
prefix?: HTTPPath;
|
35
35
|
context: T;
|
@@ -70,4 +70,5 @@ declare class StandardHandler<T extends Context> {
|
|
70
70
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
71
71
|
}
|
72
72
|
|
73
|
-
export { CompositeStandardHandlerPlugin as C,
|
73
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as i };
|
74
|
+
export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardCodec as c, StandardParams as d, StandardMatcher as e, StandardMatchResult as f, StandardHandleOptions as g, StandardHandleResult as h };
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { C as Context } from './server.
|
2
|
-
import {
|
1
|
+
import { C as Context } from './server.BVHsfJ99.js';
|
2
|
+
import { g as StandardHandleOptions } from './server.CaWivVk3.js';
|
3
3
|
|
4
4
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
5
5
|
context?: T;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { C as Context, R as Router } from './server.DLt5njUb.js';
|
2
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
3
|
-
import {
|
2
|
+
import { C as Context, R as Router } from './server.BVHsfJ99.js';
|
3
|
+
import { b as StandardHandlerOptions, i as StandardHandler } from './server.CaWivVk3.js';
|
4
4
|
|
5
5
|
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
6
|
/**
|
@@ -14,4 +14,5 @@ declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
|
|
14
14
|
constructor(router: Router<any, T>, options: StandardRPCHandlerOptions<T>);
|
15
15
|
}
|
16
16
|
|
17
|
-
export {
|
17
|
+
export { StandardRPCHandler as a };
|
18
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { C as Context } from './server.
|
2
|
-
import {
|
1
|
+
import { C as Context } from './server.BVHsfJ99.mjs';
|
2
|
+
import { g as StandardHandleOptions } from './server.B1oIHH_j.mjs';
|
3
3
|
|
4
4
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
5
5
|
context?: T;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.0.0-beta.
|
4
|
+
"version": "1.0.0-beta.7",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -34,16 +34,6 @@
|
|
34
34
|
"import": "./dist/adapters/fetch/index.mjs",
|
35
35
|
"default": "./dist/adapters/fetch/index.mjs"
|
36
36
|
},
|
37
|
-
"./hono": {
|
38
|
-
"types": "./dist/adapters/hono/index.d.mts",
|
39
|
-
"import": "./dist/adapters/hono/index.mjs",
|
40
|
-
"default": "./dist/adapters/hono/index.mjs"
|
41
|
-
},
|
42
|
-
"./next": {
|
43
|
-
"types": "./dist/adapters/next/index.d.mts",
|
44
|
-
"import": "./dist/adapters/next/index.mjs",
|
45
|
-
"default": "./dist/adapters/next/index.mjs"
|
46
|
-
},
|
47
37
|
"./node": {
|
48
38
|
"types": "./dist/adapters/node/index.d.mts",
|
49
39
|
"import": "./dist/adapters/node/index.mjs",
|
@@ -53,20 +43,16 @@
|
|
53
43
|
"files": [
|
54
44
|
"dist"
|
55
45
|
],
|
56
|
-
"peerDependencies": {
|
57
|
-
"hono": ">=4.6.0",
|
58
|
-
"next": ">=14.0.0"
|
59
|
-
},
|
60
46
|
"dependencies": {
|
61
|
-
"@orpc/
|
62
|
-
"@orpc/
|
63
|
-
"@orpc/standard-server-
|
64
|
-
"@orpc/standard-server": "1.0.0-beta.
|
65
|
-
"@orpc/
|
66
|
-
"@orpc/
|
47
|
+
"@orpc/client": "1.0.0-beta.7",
|
48
|
+
"@orpc/contract": "1.0.0-beta.7",
|
49
|
+
"@orpc/standard-server-node": "1.0.0-beta.7",
|
50
|
+
"@orpc/standard-server-fetch": "1.0.0-beta.7",
|
51
|
+
"@orpc/shared": "1.0.0-beta.7",
|
52
|
+
"@orpc/standard-server": "1.0.0-beta.7"
|
67
53
|
},
|
68
54
|
"devDependencies": {
|
69
|
-
"supertest": "^7.
|
55
|
+
"supertest": "^7.1.0"
|
70
56
|
},
|
71
57
|
"scripts": {
|
72
58
|
"build": "unbuild",
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { FetchHandler } from '../fetch/index.mjs';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
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
|
-
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.DCQgF_JR.mjs';
|
10
|
-
import '@orpc/client/standard';
|
11
|
-
import '@orpc/client';
|
12
|
-
import '@orpc/contract';
|
13
|
-
import '@orpc/standard-server';
|
14
|
-
|
15
|
-
type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
16
|
-
context?: Value<T, [Context$1]>;
|
17
|
-
} : {
|
18
|
-
context: Value<T, [Context$1]>;
|
19
|
-
});
|
20
|
-
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
21
|
-
|
22
|
-
export { type CreateMiddlewareOptions, FetchHandler, createMiddleware };
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { FetchHandler } from '../fetch/index.js';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
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
|
-
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.C8NkqxHo.js';
|
10
|
-
import '@orpc/client/standard';
|
11
|
-
import '@orpc/client';
|
12
|
-
import '@orpc/contract';
|
13
|
-
import '@orpc/standard-server';
|
14
|
-
|
15
|
-
type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
16
|
-
context?: Value<T, [Context$1]>;
|
17
|
-
} : {
|
18
|
-
context: Value<T, [Context$1]>;
|
19
|
-
});
|
20
|
-
declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
21
|
-
|
22
|
-
export { type CreateMiddlewareOptions, FetchHandler, createMiddleware };
|
@@ -1,35 +0,0 @@
|
|
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
|
-
import '@orpc/client';
|
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';
|
10
|
-
import '@orpc/standard-server-fetch';
|
11
|
-
import '../../shared/server.BVwwTHyO.mjs';
|
12
|
-
|
13
|
-
function createMiddleware(handler, ...rest) {
|
14
|
-
const options = resolveMaybeOptionalOptions(rest);
|
15
|
-
return async (c, next) => {
|
16
|
-
const bodyProps = /* @__PURE__ */ new Set(["arrayBuffer", "blob", "formData", "json", "text"]);
|
17
|
-
const request = c.req.method === "GET" || c.req.method === "HEAD" ? c.req.raw : new Proxy(c.req.raw, {
|
18
|
-
// https://github.com/honojs/middleware/blob/main/packages/trpc-server/src/index.ts#L39
|
19
|
-
get(target, prop) {
|
20
|
-
if (bodyProps.has(prop)) {
|
21
|
-
return () => c.req[prop]();
|
22
|
-
}
|
23
|
-
return Reflect.get(target, prop, target);
|
24
|
-
}
|
25
|
-
});
|
26
|
-
const context = await value(options.context ?? {}, c);
|
27
|
-
const { matched, response } = await handler.handle(request, { ...options, context });
|
28
|
-
if (matched) {
|
29
|
-
return c.newResponse(response.body, response);
|
30
|
-
}
|
31
|
-
await next();
|
32
|
-
};
|
33
|
-
}
|
34
|
-
|
35
|
-
export { createMiddleware };
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { FetchHandler } from '../fetch/index.mjs';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import { NextRequest } from 'next/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
|
-
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.DCQgF_JR.mjs';
|
10
|
-
import '@orpc/client/standard';
|
11
|
-
import '@orpc/client';
|
12
|
-
import '@orpc/contract';
|
13
|
-
import '@orpc/standard-server';
|
14
|
-
|
15
|
-
type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
16
|
-
context?: Value<T, [NextRequest]>;
|
17
|
-
} : {
|
18
|
-
context: Value<T, [NextRequest]>;
|
19
|
-
});
|
20
|
-
interface ServeResult {
|
21
|
-
GET(req: NextRequest): Promise<Response>;
|
22
|
-
POST(req: NextRequest): Promise<Response>;
|
23
|
-
PUT(req: NextRequest): Promise<Response>;
|
24
|
-
PATCH(req: NextRequest): Promise<Response>;
|
25
|
-
DELETE(req: NextRequest): Promise<Response>;
|
26
|
-
}
|
27
|
-
declare function serve<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
28
|
-
|
29
|
-
export { FetchHandler, type ServeOptions, type ServeResult, serve };
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { FetchHandler } from '../fetch/index.js';
|
2
|
-
export { BodyLimitPlugin, BodyLimitPluginOptions, CompositeFetchHandlerPlugin, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
|
3
|
-
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
-
import { NextRequest } from 'next/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
|
-
import '@orpc/standard-server-fetch';
|
9
|
-
import '../../shared/server.C8NkqxHo.js';
|
10
|
-
import '@orpc/client/standard';
|
11
|
-
import '@orpc/client';
|
12
|
-
import '@orpc/contract';
|
13
|
-
import '@orpc/standard-server';
|
14
|
-
|
15
|
-
type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
16
|
-
context?: Value<T, [NextRequest]>;
|
17
|
-
} : {
|
18
|
-
context: Value<T, [NextRequest]>;
|
19
|
-
});
|
20
|
-
interface ServeResult {
|
21
|
-
GET(req: NextRequest): Promise<Response>;
|
22
|
-
POST(req: NextRequest): Promise<Response>;
|
23
|
-
PUT(req: NextRequest): Promise<Response>;
|
24
|
-
PATCH(req: NextRequest): Promise<Response>;
|
25
|
-
DELETE(req: NextRequest): Promise<Response>;
|
26
|
-
}
|
27
|
-
declare function serve<T extends Context>(handler: FetchHandler<T>, ...rest: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
28
|
-
|
29
|
-
export { FetchHandler, type ServeOptions, type ServeResult, serve };
|
@@ -1,32 +0,0 @@
|
|
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
|
-
import '@orpc/client';
|
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';
|
10
|
-
import '@orpc/standard-server-fetch';
|
11
|
-
import '../../shared/server.BVwwTHyO.mjs';
|
12
|
-
|
13
|
-
function serve(handler, ...rest) {
|
14
|
-
const options = resolveMaybeOptionalOptions(rest);
|
15
|
-
const main = async (req) => {
|
16
|
-
const context = await value(options.context ?? {}, req);
|
17
|
-
const { matched, response } = await handler.handle(req, { ...options, context });
|
18
|
-
if (matched) {
|
19
|
-
return response;
|
20
|
-
}
|
21
|
-
return new Response(`Cannot find a matching procedure for ${req.url}`, { status: 404 });
|
22
|
-
};
|
23
|
-
return {
|
24
|
-
GET: main,
|
25
|
-
POST: main,
|
26
|
-
PUT: main,
|
27
|
-
PATCH: main,
|
28
|
-
DELETE: main
|
29
|
-
};
|
30
|
-
}
|
31
|
-
|
32
|
-
export { serve };
|
@@ -1,103 +0,0 @@
|
|
1
|
-
import { ORPCError } from '@orpc/client';
|
2
|
-
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
3
|
-
import '@orpc/contract';
|
4
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from './server.DFuJLDuo.mjs';
|
5
|
-
import '@orpc/client/standard';
|
6
|
-
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
7
|
-
import { r as resolveFriendlyStandardHandleOptions } from './server.BVwwTHyO.mjs';
|
8
|
-
import '@orpc/standard-server/batch';
|
9
|
-
|
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
|
-
if (!options2.request.body) {
|
19
|
-
return options2.next();
|
20
|
-
}
|
21
|
-
let currentBodySize = 0;
|
22
|
-
const rawReader = options2.request.body.getReader();
|
23
|
-
const reader = new ReadableStream({
|
24
|
-
start: async (controller) => {
|
25
|
-
try {
|
26
|
-
if (Number(options2.request.headers.get("content-length")) > this.maxBodySize) {
|
27
|
-
controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
while (true) {
|
31
|
-
const { done, value } = await rawReader.read();
|
32
|
-
if (done) {
|
33
|
-
break;
|
34
|
-
}
|
35
|
-
currentBodySize += value.length;
|
36
|
-
if (currentBodySize > this.maxBodySize) {
|
37
|
-
controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
|
38
|
-
break;
|
39
|
-
}
|
40
|
-
controller.enqueue(value);
|
41
|
-
}
|
42
|
-
} finally {
|
43
|
-
controller.close();
|
44
|
-
}
|
45
|
-
}
|
46
|
-
});
|
47
|
-
const requestInit = { body: reader, duplex: "half" };
|
48
|
-
return options2.next({
|
49
|
-
...options2,
|
50
|
-
request: new Request(options2.request, requestInit)
|
51
|
-
});
|
52
|
-
});
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
class CompositeFetchHandlerPlugin extends CompositeStandardHandlerPlugin {
|
57
|
-
initRuntimeAdapter(options) {
|
58
|
-
for (const plugin of this.plugins) {
|
59
|
-
plugin.initRuntimeAdapter?.(options);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
class FetchHandler {
|
65
|
-
constructor(standardHandler, options = {}) {
|
66
|
-
this.standardHandler = standardHandler;
|
67
|
-
const plugin = new CompositeFetchHandlerPlugin(options.plugins);
|
68
|
-
plugin.initRuntimeAdapter(options);
|
69
|
-
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
70
|
-
this.toFetchResponseOptions = options;
|
71
|
-
}
|
72
|
-
toFetchResponseOptions;
|
73
|
-
adapterInterceptors;
|
74
|
-
async handle(request, ...rest) {
|
75
|
-
return intercept(
|
76
|
-
this.adapterInterceptors,
|
77
|
-
{
|
78
|
-
...resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest)),
|
79
|
-
request,
|
80
|
-
toFetchResponseOptions: this.toFetchResponseOptions
|
81
|
-
},
|
82
|
-
async ({ request: request2, toFetchResponseOptions, ...options }) => {
|
83
|
-
const standardRequest = toStandardLazyRequest(request2);
|
84
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
85
|
-
if (!result.matched) {
|
86
|
-
return result;
|
87
|
-
}
|
88
|
-
return {
|
89
|
-
matched: true,
|
90
|
-
response: toFetchResponse(result.response, toFetchResponseOptions)
|
91
|
-
};
|
92
|
-
}
|
93
|
-
);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
class RPCHandler extends FetchHandler {
|
98
|
-
constructor(router, options = {}) {
|
99
|
-
super(new StandardRPCHandler(router, options), options);
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
export { BodyLimitPlugin as B, CompositeFetchHandlerPlugin as C, FetchHandler as F, RPCHandler as R };
|