@orpc/server 1.0.0-beta.5 → 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 +13 -8
- package/dist/adapters/fetch/index.d.ts +13 -8
- package/dist/adapters/fetch/index.mjs +104 -8
- package/dist/adapters/node/index.d.mts +13 -8
- package/dist/adapters/node/index.d.ts +13 -8
- package/dist/adapters/node/index.mjs +17 -12
- package/dist/adapters/standard/index.d.mts +4 -4
- package/dist/adapters/standard/index.d.ts +4 -4
- package/dist/adapters/standard/index.mjs +6 -4
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.mjs +7 -7
- package/dist/plugins/index.d.mts +101 -6
- package/dist/plugins/index.d.ts +101 -6
- package/dist/plugins/index.mjs +147 -2
- package/dist/shared/{server.CzxlqYZL.d.mts → server.B1oIHH_j.d.mts} +13 -5
- 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.BW-nUGgA.mjs +36 -0
- package/dist/shared/server.BuLPHTX1.d.mts +18 -0
- package/dist/shared/{server.e3W6AG3-.mjs → server.C37gDhSZ.mjs} +16 -22
- package/dist/shared/{server.BHlRCrf_.d.ts → server.CaWivVk3.d.ts} +13 -5
- package/dist/shared/{server.Dfx1jV-K.mjs → server.DFuJLDuo.mjs} +43 -14
- package/dist/shared/{server.Cud5qk0c.d.ts → server.DMhSfHk1.d.ts} +2 -2
- package/dist/shared/server.D_vpYits.d.ts +18 -0
- package/dist/shared/{server.DGnN7q3R.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 -32
- 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 -29
- package/dist/shared/server.B77ImKAP.d.mts +0 -8
- package/dist/shared/server.DUF89eb-.d.ts +0 -8
- package/dist/shared/server.T5WmDoWQ.mjs +0 -98
@@ -1,14 +1,21 @@
|
|
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 { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.CzxlqYZL.mjs';
|
4
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DGnN7q3R.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';
|
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,9 +23,6 @@ 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;
|
@@ -51,4 +55,5 @@ 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,
|
58
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
59
|
+
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin };
|
@@ -1,14 +1,21 @@
|
|
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 { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BHlRCrf_.js';
|
4
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.Cud5qk0c.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';
|
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,9 +23,6 @@ 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;
|
@@ -51,4 +55,5 @@ 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,
|
58
|
+
export { BodyLimitPlugin, CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
59
|
+
export type { BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin };
|
@@ -1,9 +1,105 @@
|
|
1
|
-
|
2
|
-
import '@orpc/
|
3
|
-
import '@orpc/
|
4
|
-
import '../../shared/server.
|
5
|
-
import '@orpc/shared';
|
6
|
-
import '../../shared/server.e3W6AG3-.mjs';
|
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';
|
7
5
|
import '@orpc/contract';
|
8
|
-
import '
|
9
|
-
import '
|
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';
|
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,22 +1,26 @@
|
|
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';
|
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;
|
@@ -50,4 +54,5 @@ 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,
|
57
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
58
|
+
export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin };
|
@@ -1,22 +1,26 @@
|
|
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';
|
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;
|
@@ -50,4 +54,5 @@ 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,
|
57
|
+
export { BodyLimitPlugin, CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
58
|
+
export type { BodyLimitPluginOptions, NodeHttpHandleResult, NodeHttpHandlerInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin };
|
@@ -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.Dfx1jV-K.mjs';
|
7
|
-
import '../../shared/server.e3W6AG3-.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,10 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
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 { 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 {
|
2
|
-
export {
|
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 { 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
|
|
@@ -1,6 +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';
|
6
|
-
import '
|
8
|
+
import '../../shared/server.C37gDhSZ.mjs';
|
package/dist/index.d.mts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, ClientPromiseResult } from '@orpc/client';
|
2
|
-
export { HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe } from '@orpc/client';
|
2
|
+
export { ClientContext, HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe } from '@orpc/client';
|
3
3
|
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta } from '@orpc/contract';
|
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
|
-
export { 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,
|
6
|
+
export { IntersectPick, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
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> & {
|
@@ -283,9 +283,10 @@ declare function call<TInitialContext extends Context, TInputSchema extends AnyS
|
|
283
283
|
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
284
284
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
285
285
|
};
|
286
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...
|
286
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
|
287
287
|
|
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
@@ -1,11 +1,11 @@
|
|
1
1
|
import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, ClientPromiseResult } from '@orpc/client';
|
2
|
-
export { HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe } from '@orpc/client';
|
2
|
+
export { ClientContext, HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe } from '@orpc/client';
|
3
3
|
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta } from '@orpc/contract';
|
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
|
-
export { 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,
|
6
|
+
export { IntersectPick, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
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> & {
|
@@ -283,9 +283,10 @@ declare function call<TInitialContext extends Context, TInputSchema extends AnyS
|
|
283
283
|
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
284
284
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
285
285
|
};
|
286
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...
|
286
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
|
287
287
|
|
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.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
|
2
2
|
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
-
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure, g as getRouter } from './shared/server.
|
4
|
-
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.
|
3
|
+
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure, g as getRouter } from './shared/server.C37gDhSZ.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.C37gDhSZ.mjs';
|
5
5
|
import { toORPCError } from '@orpc/client';
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
7
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
@@ -336,12 +336,12 @@ function implement(contract, config = {}) {
|
|
336
336
|
return impl;
|
337
337
|
}
|
338
338
|
|
339
|
-
function createRouterClient(router, ...
|
339
|
+
function createRouterClient(router, ...rest) {
|
340
340
|
if (isProcedure(router)) {
|
341
|
-
const caller = createProcedureClient(router,
|
341
|
+
const caller = createProcedureClient(router, ...rest);
|
342
342
|
return caller;
|
343
343
|
}
|
344
|
-
const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router),
|
344
|
+
const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), ...rest) : {};
|
345
345
|
const recursive = new Proxy(procedureCaller, {
|
346
346
|
get(target, key) {
|
347
347
|
if (typeof key !== "string") {
|
@@ -352,8 +352,8 @@ function createRouterClient(router, ...[options]) {
|
|
352
352
|
return Reflect.get(target, key);
|
353
353
|
}
|
354
354
|
return createRouterClient(next, {
|
355
|
-
...
|
356
|
-
path: [...
|
355
|
+
...rest[0],
|
356
|
+
path: [...rest[0]?.path ?? [], key]
|
357
357
|
});
|
358
358
|
}
|
359
359
|
});
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,9 +1,46 @@
|
|
1
|
-
import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.CzxlqYZL.mjs';
|
2
1
|
import { Value } from '@orpc/shared';
|
3
|
-
import {
|
4
|
-
import '@orpc/
|
5
|
-
import '
|
6
|
-
import '
|
2
|
+
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
|
+
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
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
|
+
import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
|
7
|
+
import { ORPCError } from '@orpc/client';
|
8
|
+
|
9
|
+
interface BatchHandlerOptions<T extends Context> {
|
10
|
+
/**
|
11
|
+
* The max size of the batch allowed.
|
12
|
+
*
|
13
|
+
* @default 10
|
14
|
+
*/
|
15
|
+
maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
|
16
|
+
/**
|
17
|
+
* Map the request before processing it.
|
18
|
+
*
|
19
|
+
* @default merged back batch request headers into the request
|
20
|
+
*/
|
21
|
+
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
22
|
+
/**
|
23
|
+
* Success batch response status code.
|
24
|
+
*
|
25
|
+
* @default 207
|
26
|
+
*/
|
27
|
+
successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
|
28
|
+
/**
|
29
|
+
* success batch response headers.
|
30
|
+
*
|
31
|
+
* @default {}
|
32
|
+
*/
|
33
|
+
headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
|
34
|
+
}
|
35
|
+
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
36
|
+
private readonly maxSize;
|
37
|
+
private readonly mapRequestItem;
|
38
|
+
private readonly successStatus;
|
39
|
+
private readonly headers;
|
40
|
+
order: number;
|
41
|
+
constructor(options?: BatchHandlerOptions<T>);
|
42
|
+
init(options: StandardHandlerOptions<T>): void;
|
43
|
+
}
|
7
44
|
|
8
45
|
interface CORSOptions<T extends Context> {
|
9
46
|
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
@@ -16,6 +53,7 @@ interface CORSOptions<T extends Context> {
|
|
16
53
|
}
|
17
54
|
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
18
55
|
private readonly options;
|
56
|
+
order: number;
|
19
57
|
constructor(options?: CORSOptions<T>);
|
20
58
|
init(options: StandardHandlerOptions<T>): void;
|
21
59
|
}
|
@@ -27,4 +65,61 @@ declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> impl
|
|
27
65
|
init(options: StandardHandlerOptions<T>): void;
|
28
66
|
}
|
29
67
|
|
30
|
-
|
68
|
+
interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
|
69
|
+
/**
|
70
|
+
* The name of the header to check.
|
71
|
+
*
|
72
|
+
* @default 'x-csrf-token'
|
73
|
+
*/
|
74
|
+
headerName?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
|
75
|
+
/**
|
76
|
+
* The value of the header to check.
|
77
|
+
*
|
78
|
+
* @default 'orpc'
|
79
|
+
*
|
80
|
+
*/
|
81
|
+
headerValue?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
|
82
|
+
/**
|
83
|
+
* Exclude a procedure from the plugin.
|
84
|
+
*
|
85
|
+
* @default false
|
86
|
+
*
|
87
|
+
*/
|
88
|
+
exclude?: Value<boolean, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
|
89
|
+
/**
|
90
|
+
* The error thrown when the CSRF token is invalid.
|
91
|
+
*
|
92
|
+
* @default new ORPCError('CSRF_TOKEN_MISMATCH', {
|
93
|
+
* status: 403,
|
94
|
+
* message: 'Invalid CSRF token',
|
95
|
+
* })
|
96
|
+
*/
|
97
|
+
error?: InstanceType<typeof ORPCError>;
|
98
|
+
}
|
99
|
+
declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
100
|
+
private readonly headerName;
|
101
|
+
private readonly headerValue;
|
102
|
+
private readonly exclude;
|
103
|
+
private readonly error;
|
104
|
+
constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
|
105
|
+
order: number;
|
106
|
+
init(options: StandardHandlerOptions<T>): void;
|
107
|
+
}
|
108
|
+
|
109
|
+
interface StrictGetMethodPluginOptions {
|
110
|
+
/**
|
111
|
+
* The error thrown when a GET request is made to a procedure that doesn't allow GET.
|
112
|
+
*
|
113
|
+
* @default new ORPCError('METHOD_NOT_SUPPORTED')
|
114
|
+
*/
|
115
|
+
error?: InstanceType<typeof ORPCError$1>;
|
116
|
+
}
|
117
|
+
declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
118
|
+
private readonly error;
|
119
|
+
order: number;
|
120
|
+
constructor(options?: StrictGetMethodPluginOptions);
|
121
|
+
init(options: StandardHandlerOptions<T>): void;
|
122
|
+
}
|
123
|
+
|
124
|
+
export { BatchHandlerPlugin, CORSPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
|
125
|
+
export type { BatchHandlerOptions, CORSOptions, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions };
|