@orpc/server 1.14.10 → 1.14.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -98
- package/dist/adapters/crossws/index.d.mts +45 -21
- package/dist/adapters/crossws/index.d.ts +45 -21
- package/dist/adapters/crossws/index.mjs +40 -18
- package/dist/adapters/fetch/index.d.mts +64 -96
- package/dist/adapters/fetch/index.d.ts +64 -96
- package/dist/adapters/fetch/index.mjs +34 -139
- package/dist/adapters/message-port/index.d.mts +49 -34
- package/dist/adapters/message-port/index.d.ts +49 -34
- package/dist/adapters/message-port/index.mjs +68 -37
- package/dist/adapters/node/index.d.mts +63 -71
- package/dist/adapters/node/index.d.ts +63 -71
- package/dist/adapters/node/index.mjs +36 -113
- package/dist/adapters/standard/index.d.mts +16 -18
- package/dist/adapters/standard/index.d.ts +16 -18
- package/dist/adapters/standard/index.mjs +5 -5
- package/dist/adapters/standard-peer/index.d.mts +12 -14
- package/dist/adapters/standard-peer/index.d.ts +12 -14
- package/dist/adapters/standard-peer/index.mjs +2 -21
- package/dist/adapters/websocket/index.d.mts +53 -38
- package/dist/adapters/websocket/index.d.ts +53 -38
- package/dist/adapters/websocket/index.mjs +59 -42
- package/dist/extensions/callable.d.mts +10 -0
- package/dist/extensions/callable.d.ts +10 -0
- package/dist/extensions/callable.mjs +11 -0
- package/dist/helpers/index.d.mts +4 -4
- package/dist/helpers/index.d.ts +4 -4
- package/dist/helpers/index.mjs +13 -5
- package/dist/index.d.mts +166 -770
- package/dist/index.d.ts +166 -770
- package/dist/index.mjs +306 -399
- package/dist/plugins/index.d.mts +214 -121
- package/dist/plugins/index.d.ts +214 -121
- package/dist/plugins/index.mjs +576 -214
- package/dist/shared/server.15O7oC1p.d.mts +61 -0
- package/dist/shared/server.B4BnEWWm.d.mts +67 -0
- package/dist/shared/server.BhsVw7m7.d.ts +104 -0
- package/dist/shared/server.BoiFpNT7.mjs +224 -0
- package/dist/shared/server.COPVXhDG.mjs +271 -0
- package/dist/shared/server.CX4vUnDk.mjs +11 -0
- package/dist/shared/server.CcR4kgje.d.mts +206 -0
- package/dist/shared/server.CcR4kgje.d.ts +206 -0
- package/dist/shared/server.CnN50DHH.d.ts +67 -0
- package/dist/shared/server.DBs0rrf9.mjs +41 -0
- package/dist/shared/server.DDFizwfU.d.mts +104 -0
- package/dist/shared/server.D_QauotT.mjs +30 -0
- package/dist/shared/server.DofEOwf-.mjs +237 -0
- package/dist/shared/{server.DZ5BIITo.mjs → server.W91HSRkE.mjs} +2 -2
- package/dist/shared/server.m3szVJGU.d.ts +61 -0
- package/package.json +26 -56
- package/dist/adapters/aws-lambda/index.d.mts +0 -46
- package/dist/adapters/aws-lambda/index.d.ts +0 -46
- package/dist/adapters/aws-lambda/index.mjs +0 -40
- package/dist/adapters/bun-ws/index.d.mts +0 -36
- package/dist/adapters/bun-ws/index.d.ts +0 -36
- package/dist/adapters/bun-ws/index.mjs +0 -47
- package/dist/adapters/fastify/index.d.mts +0 -53
- package/dist/adapters/fastify/index.d.ts +0 -53
- package/dist/adapters/fastify/index.mjs +0 -52
- package/dist/adapters/ws/index.d.mts +0 -31
- package/dist/adapters/ws/index.d.ts +0 -31
- package/dist/adapters/ws/index.mjs +0 -41
- package/dist/hibernation/index.d.mts +0 -44
- package/dist/hibernation/index.d.ts +0 -44
- package/dist/hibernation/index.mjs +0 -65
- package/dist/shared/server.7cEtMB30.d.ts +0 -74
- package/dist/shared/server.B8gYOD5g.d.mts +0 -12
- package/dist/shared/server.BqadksTP.d.mts +0 -74
- package/dist/shared/server.C8_sRzQB.d.mts +0 -42
- package/dist/shared/server.ChUyt5-i.d.mts +0 -32
- package/dist/shared/server.ChyoA9XY.d.ts +0 -42
- package/dist/shared/server.DEBcqOjg.mjs +0 -418
- package/dist/shared/server.EfTOZ2Q7.d.ts +0 -12
- package/dist/shared/server.TEVCLCFC.mjs +0 -39
- package/dist/shared/server.ZxHCEN1h.mjs +0 -226
- package/dist/shared/server.qKsRrdxW.d.mts +0 -193
- package/dist/shared/server.qKsRrdxW.d.ts +0 -193
- package/dist/shared/server.yoEB3Fx4.d.ts +0 -32
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,204 +1,297 @@
|
|
|
1
1
|
import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { ORPCError } from '@orpc/client';
|
|
2
|
+
import { StandardLazyRequest, StandardHeaders } from '@standardserver/core';
|
|
3
|
+
import { C as Context } from '../shared/server.CcR4kgje.mjs';
|
|
4
|
+
import { e as StandardHandlerPlugin, f as StandardHandlerRoutingInterceptorOptions, a as StandardHandlerOptions, g as StandardHandlerInterceptorOptions } from '../shared/server.DDFizwfU.mjs';
|
|
5
|
+
import '@orpc/client';
|
|
6
|
+
import '@orpc/contract';
|
|
8
7
|
|
|
9
|
-
interface
|
|
8
|
+
interface BatchHandlerPluginOptions<T extends Context> {
|
|
10
9
|
/**
|
|
11
10
|
* The max size of the batch allowed.
|
|
12
11
|
*
|
|
13
12
|
* @default 10
|
|
14
13
|
*/
|
|
15
|
-
maxSize?: Value<Promisable<number>, [
|
|
14
|
+
maxSize?: Value<Promisable<number>, [options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
16
15
|
/**
|
|
17
|
-
* Map the
|
|
16
|
+
* Map each subrequest in the batch before it is processed.
|
|
18
17
|
*
|
|
19
|
-
* @default
|
|
18
|
+
* @default merges the batch request headers into the subrequest and remove `orpc-batch` header to prevent nested batching
|
|
20
19
|
*/
|
|
21
|
-
|
|
20
|
+
mapSubrequest?: (subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest;
|
|
22
21
|
/**
|
|
23
22
|
* Success batch response status code.
|
|
24
23
|
*
|
|
25
24
|
* @default 207
|
|
26
25
|
*/
|
|
27
|
-
successStatus?: Value<Promisable<number>, [
|
|
26
|
+
successStatus?: Value<Promisable<number>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
28
|
+
* Success batch response headers.
|
|
30
29
|
*
|
|
31
30
|
* @default {}
|
|
32
31
|
*/
|
|
33
|
-
headers?: Value<Promisable<StandardHeaders>, [
|
|
32
|
+
headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
33
|
+
/**
|
|
34
|
+
* Keep-alive settings for streaming batch responses.
|
|
35
|
+
*
|
|
36
|
+
* When enabled, a zero-length length-prefixed frame is sent periodically while the
|
|
37
|
+
* stream is idle (no message sent for `interval` ms). Clients ignore these frames.
|
|
38
|
+
* Only applies to streaming mode.
|
|
39
|
+
*
|
|
40
|
+
* @default { enabled: true, interval: 15000 }
|
|
41
|
+
*/
|
|
42
|
+
keepAlive?: undefined | {
|
|
43
|
+
/**
|
|
44
|
+
* If true, a keep-alive frame is sent periodically while the stream is idle.
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Interval (in milliseconds) between keep-alive frames after the last message.
|
|
51
|
+
*
|
|
52
|
+
* @default 15000
|
|
53
|
+
*/
|
|
54
|
+
interval?: number;
|
|
55
|
+
};
|
|
34
56
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
|
|
37
|
-
* reducing the overhead of sending each one separately.
|
|
38
|
-
*
|
|
39
|
-
* @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
|
|
40
|
-
*/
|
|
41
57
|
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
58
|
+
name: string;
|
|
59
|
+
/**
|
|
60
|
+
* Run batch interceptors before OpenTelemetry interceptors
|
|
61
|
+
* so each subrequest gets its own span instead of sharing one batch-level span.
|
|
62
|
+
*/
|
|
63
|
+
after: string[];
|
|
42
64
|
private readonly maxSize;
|
|
43
|
-
private readonly
|
|
65
|
+
private readonly mapSubrequest;
|
|
44
66
|
private readonly successStatus;
|
|
45
67
|
private readonly headers;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
private readonly keepAliveEnabled;
|
|
69
|
+
private readonly keepAliveInterval;
|
|
70
|
+
constructor(options?: BatchHandlerPluginOptions<T>);
|
|
71
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
49
72
|
}
|
|
50
73
|
|
|
51
|
-
interface
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
interface CORSHandlerPluginOptions<T extends Context> {
|
|
75
|
+
/**
|
|
76
|
+
* Configures the `Access-Control-Allow-Origin` header.
|
|
77
|
+
* Can be a string, an array of allowed origins, or a function that returns the allowed origin(s).
|
|
78
|
+
*
|
|
79
|
+
* @default (origin) => origin
|
|
80
|
+
*/
|
|
81
|
+
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
82
|
+
/**
|
|
83
|
+
* Configures the `Timing-Allow-Origin` header.
|
|
84
|
+
* Can be a string, an array of allowed origins, or a function that returns the allowed origin(s).
|
|
85
|
+
*
|
|
86
|
+
* @default undefined
|
|
87
|
+
*/
|
|
88
|
+
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
89
|
+
/**
|
|
90
|
+
* Configures the `Access-Control-Allow-Methods` header for preflight requests.
|
|
91
|
+
*
|
|
92
|
+
* @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']
|
|
93
|
+
*/
|
|
54
94
|
allowMethods?: readonly string[];
|
|
95
|
+
/**
|
|
96
|
+
* Configures the `Access-Control-Allow-Headers` header for preflight requests.
|
|
97
|
+
* Falls back to the request's `Access-Control-Request-Headers` if not set.
|
|
98
|
+
*
|
|
99
|
+
* @default undefined
|
|
100
|
+
*/
|
|
55
101
|
allowHeaders?: readonly string[];
|
|
102
|
+
/**
|
|
103
|
+
* Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
|
|
104
|
+
*
|
|
105
|
+
* @default undefined
|
|
106
|
+
*/
|
|
56
107
|
maxAge?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Configures the `Access-Control-Allow-Credentials` header.
|
|
110
|
+
*
|
|
111
|
+
* @default undefined
|
|
112
|
+
*/
|
|
57
113
|
credentials?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Configures the `Access-Control-Expose-Headers` header.
|
|
116
|
+
*
|
|
117
|
+
* @default undefined
|
|
118
|
+
*/
|
|
58
119
|
exposeHeaders?: readonly string[];
|
|
59
120
|
}
|
|
60
121
|
/**
|
|
61
|
-
*
|
|
122
|
+
* CORSHandlerPlugin is a plugin for oRPC that allows you to configure CORS for your API.
|
|
62
123
|
*
|
|
63
124
|
* @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin Docs}
|
|
64
125
|
*/
|
|
65
|
-
declare class
|
|
126
|
+
declare class CORSHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
66
127
|
private readonly options;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
128
|
+
name: string;
|
|
129
|
+
/**
|
|
130
|
+
* - Do not create spans for CORS preflight requests.
|
|
131
|
+
* - Run CORS interceptors before batch interceptors so headers are applied to
|
|
132
|
+
* the actual response rather than sub-responses.
|
|
133
|
+
*/
|
|
134
|
+
after: string[];
|
|
135
|
+
constructor(options?: CORSHandlerPluginOptions<T>);
|
|
136
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
70
137
|
}
|
|
71
138
|
|
|
72
|
-
interface RequestHeadersPluginContext {
|
|
73
|
-
reqHeaders?: Headers;
|
|
74
|
-
}
|
|
75
139
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
140
|
+
* Adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
|
|
141
|
+
* When a request includes cookies, it helps ensure the request originates from JavaScript
|
|
142
|
+
* (for example, fetch/XHR) rather than from standard HTML forms or direct browser navigation.
|
|
78
143
|
*
|
|
79
|
-
* @
|
|
144
|
+
* @info This plugin is enabled by default for `RPCHandler` over HTTP.
|
|
80
145
|
*/
|
|
81
|
-
declare class
|
|
82
|
-
|
|
146
|
+
declare class CSRFGuardHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
147
|
+
name: string;
|
|
148
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
83
149
|
}
|
|
84
150
|
|
|
85
|
-
|
|
86
|
-
|
|
151
|
+
declare class RequestCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
152
|
+
name: string;
|
|
153
|
+
/**
|
|
154
|
+
* Should decompress the original batch request body instead of sub-requests.
|
|
155
|
+
*/
|
|
156
|
+
after: string[];
|
|
157
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface RequestHeadersHandlerPluginContext {
|
|
161
|
+
/**
|
|
162
|
+
* Request headers as a Headers instance. This is injected by the Request Headers Plugin.
|
|
163
|
+
*/
|
|
164
|
+
reqHeaders?: Headers | undefined;
|
|
87
165
|
}
|
|
88
166
|
/**
|
|
89
|
-
* The
|
|
90
|
-
*
|
|
167
|
+
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
168
|
+
* allowing access to request headers in oRPC.
|
|
91
169
|
*
|
|
92
|
-
* @see {@link https://orpc.dev/docs/plugins/
|
|
170
|
+
* @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
|
|
93
171
|
*/
|
|
94
|
-
declare class
|
|
95
|
-
|
|
172
|
+
declare class RequestHeadersHandlerPlugin<T extends RequestHeadersHandlerPluginContext> implements StandardHandlerPlugin<T> {
|
|
173
|
+
name: string;
|
|
174
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
96
175
|
}
|
|
97
176
|
|
|
98
|
-
interface
|
|
177
|
+
interface RequestLimitHandlerPluginOptions {
|
|
99
178
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* const rethrowPlugin = new RethrowHandlerPlugin({
|
|
105
|
-
* filter: (error) => {
|
|
106
|
-
* // Rethrow all non-ORPCError errors
|
|
107
|
-
* return !(error instanceof ORPCError)
|
|
108
|
-
* }
|
|
109
|
-
* })
|
|
110
|
-
* ```
|
|
179
|
+
* The maximum allowed request body size in bytes.
|
|
111
180
|
*/
|
|
112
|
-
|
|
181
|
+
maxBodySize: number;
|
|
113
182
|
}
|
|
114
183
|
/**
|
|
115
|
-
*
|
|
116
|
-
* This is particularly useful when your framework has its own error handling mechanism
|
|
117
|
-
* (e.g., global exception filters in NestJS, error middleware in Express)
|
|
118
|
-
* and you want certain errors to be processed by that mechanism instead of being handled by the
|
|
119
|
-
* oRPC error handling flow.
|
|
184
|
+
* Rejects requests whose body exceeds `maxBodySize`.
|
|
120
185
|
*
|
|
121
|
-
*
|
|
186
|
+
* When used with the request compression plugin, the limit applies to the
|
|
187
|
+
* decompressed payload rather than the compressed wire size.
|
|
188
|
+
*
|
|
189
|
+
* @see {@link https://orpc.dev/docs/plugins/request-limit Request Limit Plugin Docs}
|
|
122
190
|
*/
|
|
123
|
-
declare class
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
191
|
+
declare class RequestLimitHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
192
|
+
name: string;
|
|
193
|
+
/**
|
|
194
|
+
* Should limit the original batch request body instead of sub-requests.
|
|
195
|
+
*/
|
|
196
|
+
after: string[];
|
|
197
|
+
/**
|
|
198
|
+
* Should limit the final body size instead of the compressed one.
|
|
199
|
+
*/
|
|
200
|
+
before: string[];
|
|
201
|
+
private readonly maxBodySize;
|
|
202
|
+
constructor(options: RequestLimitHandlerPluginOptions);
|
|
203
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
128
204
|
}
|
|
129
205
|
|
|
130
|
-
interface
|
|
206
|
+
interface ResponseCompressionHandlerPluginOptions<_T extends Context> {
|
|
131
207
|
/**
|
|
132
|
-
* The
|
|
208
|
+
* The compression schemes to use for response compression.
|
|
209
|
+
* Schemes are prioritized by their order in this array and
|
|
210
|
+
* only applied if the client supports them (via Accept-Encoding).
|
|
133
211
|
*
|
|
134
|
-
* @default '
|
|
212
|
+
* @default ['gzip', 'deflate']
|
|
135
213
|
*/
|
|
136
|
-
|
|
214
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
137
215
|
/**
|
|
138
|
-
* The
|
|
139
|
-
*
|
|
140
|
-
*
|
|
216
|
+
* The minimum response size in bytes required to trigger compression.
|
|
217
|
+
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
218
|
+
* If the response size cannot be determined, compression will still be applied.
|
|
141
219
|
*
|
|
220
|
+
* @default 1024 (1KB)
|
|
142
221
|
*/
|
|
143
|
-
|
|
222
|
+
threshold?: number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Compresses response bodies based on the client's Accept-Encoding header.
|
|
226
|
+
* Works at the standard handler level, so it supports all adapters.
|
|
227
|
+
*
|
|
228
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin Docs}
|
|
229
|
+
*/
|
|
230
|
+
declare class ResponseCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
231
|
+
name: string;
|
|
144
232
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* @default false
|
|
148
|
-
*
|
|
233
|
+
* Compression should be done after batching, to compress the final response.
|
|
234
|
+
* Compression should also be done after response headers are set, to access final headers like Content-Type and Cache-Control.
|
|
149
235
|
*/
|
|
150
|
-
|
|
236
|
+
after: string[];
|
|
237
|
+
private readonly encodings;
|
|
238
|
+
private readonly threshold;
|
|
239
|
+
constructor(options?: ResponseCompressionHandlerPluginOptions<T>);
|
|
240
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface ResponseHeadersHandlerPluginContext {
|
|
151
244
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* @default new ORPCError('CSRF_TOKEN_MISMATCH', {
|
|
155
|
-
* status: 403,
|
|
156
|
-
* message: 'Invalid CSRF token',
|
|
157
|
-
* })
|
|
245
|
+
* Response headers as a Headers instance. This is injected by the Response Headers Plugin.
|
|
246
|
+
* When set before the response is sent, these headers will be included in the response. If not set, no additional headers will be added.
|
|
158
247
|
*/
|
|
159
|
-
|
|
248
|
+
resHeaders?: Headers | undefined;
|
|
160
249
|
}
|
|
161
250
|
/**
|
|
162
|
-
*
|
|
163
|
-
* It
|
|
164
|
-
* not from other sources like standard HTML forms or direct browser navigation.
|
|
251
|
+
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
252
|
+
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
165
253
|
*
|
|
166
|
-
* @see {@link https://orpc.dev/docs/plugins/
|
|
254
|
+
* @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin Docs}
|
|
167
255
|
*/
|
|
168
|
-
declare class
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
256
|
+
declare class ResponseHeadersHandlerPlugin<T extends ResponseHeadersHandlerPluginContext> implements StandardHandlerPlugin<T> {
|
|
257
|
+
name: string;
|
|
258
|
+
/**
|
|
259
|
+
* Interceptors should run after batch interceptors so headers are applied to each sub-response.
|
|
260
|
+
*/
|
|
261
|
+
before: string[];
|
|
262
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
176
263
|
}
|
|
177
264
|
|
|
178
|
-
interface
|
|
265
|
+
interface RethrowHandlerPluginOptions<T extends Context> {
|
|
179
266
|
/**
|
|
180
|
-
*
|
|
267
|
+
* Decide which errors should be rethrown.
|
|
181
268
|
*
|
|
182
|
-
* @
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* const rethrowPlugin = new RethrowHandlerPlugin({
|
|
272
|
+
* filter: (error) => {
|
|
273
|
+
* // Rethrow all non-ORPCError errors
|
|
274
|
+
* return !(error instanceof ORPCError)
|
|
275
|
+
* }
|
|
276
|
+
* })
|
|
277
|
+
* ```
|
|
183
278
|
*/
|
|
184
|
-
error
|
|
279
|
+
filter: (error: ThrowableError, options: StandardHandlerInterceptorOptions<T>) => boolean;
|
|
185
280
|
}
|
|
186
281
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
282
|
+
* The plugin can bypass oRPC's built-in error handling
|
|
283
|
+
* and rethrow matching errors directly to your framework's error handling mechanism
|
|
284
|
+
* (e.g., NestJS exception filters, Express error middleware).
|
|
190
285
|
*
|
|
191
|
-
* @see {@link https://orpc.dev/docs/plugins/
|
|
286
|
+
* @see {@link https://orpc.dev/docs/plugins/rethrow Rethrow Plugin Documentation}
|
|
192
287
|
*/
|
|
193
|
-
declare class
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
constructor(options?: StrictGetMethodPluginOptions);
|
|
200
|
-
init(options: StandardHandlerOptions<T>): void;
|
|
288
|
+
declare class RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
289
|
+
name: string;
|
|
290
|
+
private readonly filter;
|
|
291
|
+
private readonly CONTEXT_SYMBOL;
|
|
292
|
+
constructor(options: RethrowHandlerPluginOptions<T>);
|
|
293
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
201
294
|
}
|
|
202
295
|
|
|
203
|
-
export { BatchHandlerPlugin,
|
|
204
|
-
export type {
|
|
296
|
+
export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestLimitHandlerPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
|
|
297
|
+
export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestLimitHandlerPluginOptions, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };
|