@orpc/server 2.0.0-beta.3 → 2.0.0-beta.31
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 +71 -101
- package/dist/adapters/aws-lambda/index.d.mts +93 -0
- package/dist/adapters/aws-lambda/index.d.ts +93 -0
- package/dist/adapters/aws-lambda/index.mjs +66 -0
- package/dist/adapters/crossws/index.d.mts +17 -8
- package/dist/adapters/crossws/index.d.ts +17 -8
- package/dist/adapters/crossws/index.mjs +10 -7
- package/dist/adapters/fastify/index.d.mts +85 -0
- package/dist/adapters/fastify/index.d.ts +85 -0
- package/dist/adapters/fastify/index.mjs +66 -0
- package/dist/adapters/fetch/index.d.mts +16 -67
- package/dist/adapters/fetch/index.d.ts +16 -67
- package/dist/adapters/fetch/index.mjs +8 -144
- package/dist/adapters/message-port/index.d.mts +19 -16
- package/dist/adapters/message-port/index.d.ts +19 -16
- package/dist/adapters/message-port/index.mjs +28 -32
- package/dist/adapters/node/index.d.mts +15 -49
- package/dist/adapters/node/index.d.ts +15 -49
- package/dist/adapters/node/index.mjs +9 -120
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/standard-peer/index.d.mts +2 -2
- package/dist/adapters/standard-peer/index.d.ts +2 -2
- package/dist/adapters/websocket/index.d.mts +42 -26
- package/dist/adapters/websocket/index.d.ts +42 -26
- package/dist/adapters/websocket/index.mjs +33 -25
- package/dist/extensions/callable.d.mts +2 -2
- package/dist/extensions/callable.d.ts +2 -2
- package/dist/extensions/callable.mjs +2 -2
- package/dist/helpers/index.d.mts +23 -6
- package/dist/helpers/index.d.ts +23 -6
- package/dist/helpers/index.mjs +13 -5
- package/dist/index.d.mts +311 -16
- package/dist/index.d.ts +311 -16
- package/dist/index.mjs +126 -34
- package/dist/plugins/index.d.mts +241 -32
- package/dist/plugins/index.d.ts +241 -32
- package/dist/plugins/index.mjs +479 -15
- package/dist/shared/server.BhHrioCw.d.ts +34 -0
- package/dist/shared/{server.T9F3bzZx.d.ts → server.C2n16pp0.d.ts} +34 -9
- package/dist/shared/server.Cd4Z1hpV.mjs +69 -0
- package/dist/shared/{server.CrlKQucM.mjs → server.CkButhNT.mjs} +21 -38
- package/dist/shared/{server.B_U9y00a.d.mts → server.CkNnZ5F-.d.mts} +34 -9
- package/dist/shared/{server.BL22TloH.d.mts → server.CwrYlF72.d.mts} +31 -41
- package/dist/shared/{server.BL22TloH.d.ts → server.CwrYlF72.d.ts} +31 -41
- package/dist/shared/server.D0Ipbmdv.d.mts +34 -0
- package/dist/shared/{server.BwHnWUuN.mjs → server.Dh77P3ii.mjs} +17 -10
- package/dist/shared/{server.Pa0F03f_.d.ts → server.Dm0os-OP.d.mts} +24 -12
- package/dist/shared/{server.GDpX6Df8.mjs → server.DpUGXBi2.mjs} +84 -51
- package/dist/shared/{server.EOHJ3NJr.d.ts → server.DrN1Pj1-.d.ts} +3 -3
- package/dist/shared/{server.BsNNjG5J.d.mts → server.DtfwuV6U.d.ts} +24 -12
- package/dist/shared/{server.BB_Ik9Ph.d.mts → server.JbCIPL4P.d.mts} +3 -3
- package/dist/shared/{server.CjOb6ItT.mjs → server.eCTV8Vpp.mjs} +1 -1
- package/package.json +46 -12
- package/dist/shared/server.D_QauotT.mjs +0 -30
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
-
import { StandardLazyRequest, StandardHeaders } from '@standardserver/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Value, Promisable, ThrowableError } from '@orpc/shared';
|
|
2
|
+
import { StandardLazyRequest, StandardHeaders, StandardMethod } from '@standardserver/core';
|
|
3
|
+
import { Context } from '../index.mjs';
|
|
4
|
+
import { StandardHandlerPlugin, StandardHandlerRoutingInterceptorOptions, StandardHandlerOptions, StandardHandlerInterceptorOptions } from '../adapters/standard/index.mjs';
|
|
5
|
+
export { R as RequestLimitHandlerPlugin, a as RequestLimitHandlerPluginOptions } from '../shared/server.D0Ipbmdv.mjs';
|
|
5
6
|
import '@orpc/client';
|
|
6
7
|
import '@orpc/contract';
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Content type for batch responses that use the length-prefixed binary framing
|
|
11
|
+
* (streaming mode, and buffered mode when any sub-response contains binary).
|
|
12
|
+
*
|
|
13
|
+
* Decoding is driven by the `standard-server` body hint, not this header,
|
|
14
|
+
* so it only serves to describe the payload to logs, proxies, and dev tools.
|
|
15
|
+
*/
|
|
16
|
+
declare const BATCH_CONTENT_TYPE = "application/vnd.orpc.batch";
|
|
8
17
|
interface BatchHandlerPluginOptions<T extends Context> {
|
|
9
18
|
/**
|
|
10
19
|
* The max size of the batch allowed.
|
|
@@ -15,7 +24,8 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
15
24
|
/**
|
|
16
25
|
* Map each subrequest in the batch before it is processed.
|
|
17
26
|
*
|
|
18
|
-
* @default merges the batch request headers into the subrequest
|
|
27
|
+
* @default merges the batch request headers into the subrequest, giving them priority over
|
|
28
|
+
* the subrequest headers, and removes the `orpc-batch` header to prevent nested batching
|
|
19
29
|
*/
|
|
20
30
|
mapSubrequest?: (subrequest: StandardLazyRequest, batchOptions: StandardHandlerRoutingInterceptorOptions<T>) => StandardLazyRequest;
|
|
21
31
|
/**
|
|
@@ -30,7 +40,39 @@ interface BatchHandlerPluginOptions<T extends Context> {
|
|
|
30
40
|
* @default {}
|
|
31
41
|
*/
|
|
32
42
|
headers?: Value<Promisable<StandardHeaders>, [batchOptions: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
43
|
+
/**
|
|
44
|
+
* Keep-alive settings for streaming batch responses.
|
|
45
|
+
*
|
|
46
|
+
* When enabled, a zero-length length-prefixed frame is sent periodically while the
|
|
47
|
+
* stream is idle (no message sent for `interval` ms). Clients ignore these frames.
|
|
48
|
+
* Only applies to streaming mode.
|
|
49
|
+
*
|
|
50
|
+
* @default { enabled: true, interval: 15000 }
|
|
51
|
+
*/
|
|
52
|
+
keepAlive?: undefined | {
|
|
53
|
+
/**
|
|
54
|
+
* If true, a keep-alive frame is sent periodically while the stream is idle.
|
|
55
|
+
*
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Interval (in milliseconds) between keep-alive frames after the last message.
|
|
61
|
+
*
|
|
62
|
+
* @default 15000
|
|
63
|
+
*/
|
|
64
|
+
interval?: number;
|
|
65
|
+
};
|
|
33
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Handles batch requests sent by the client Batch Link Plugin, splitting each
|
|
69
|
+
* batch into sub-requests and streaming their responses back together.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* **Note**: HTTP/2 and later already multiplex requests over a single connection, which often makes this plugin unnecessary.
|
|
73
|
+
*
|
|
74
|
+
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
75
|
+
*/
|
|
34
76
|
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
35
77
|
name: string;
|
|
36
78
|
/**
|
|
@@ -42,6 +84,8 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
|
|
|
42
84
|
private readonly mapSubrequest;
|
|
43
85
|
private readonly successStatus;
|
|
44
86
|
private readonly headers;
|
|
87
|
+
private readonly keepAliveEnabled;
|
|
88
|
+
private readonly keepAliveInterval;
|
|
45
89
|
constructor(options?: BatchHandlerPluginOptions<T>);
|
|
46
90
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
47
91
|
}
|
|
@@ -49,54 +93,45 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
|
|
|
49
93
|
interface CORSHandlerPluginOptions<T extends Context> {
|
|
50
94
|
/**
|
|
51
95
|
* Configures the `Access-Control-Allow-Origin` header.
|
|
52
|
-
* Can be a string, an array of allowed origins, or a function that returns the allowed origin(s).
|
|
96
|
+
* Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
|
|
53
97
|
*
|
|
54
|
-
* @default
|
|
98
|
+
* @default '*'
|
|
55
99
|
*/
|
|
56
|
-
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
100
|
+
origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string | undefined, options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
57
101
|
/**
|
|
58
102
|
* Configures the `Timing-Allow-Origin` header.
|
|
59
|
-
* Can be a string, an array of allowed origins, or a function that returns the allowed origin(s).
|
|
60
|
-
*
|
|
61
|
-
* @default undefined
|
|
103
|
+
* Can be a string, an array of allowed origins, or a function (optionally async) that returns the allowed origin(s).
|
|
62
104
|
*/
|
|
63
|
-
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
105
|
+
timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string | undefined, options: StandardHandlerRoutingInterceptorOptions<T>]>;
|
|
64
106
|
/**
|
|
65
107
|
* Configures the `Access-Control-Allow-Methods` header for preflight requests.
|
|
66
108
|
*
|
|
67
|
-
* @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']
|
|
109
|
+
* @default ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY']
|
|
68
110
|
*/
|
|
69
111
|
allowMethods?: readonly string[];
|
|
70
112
|
/**
|
|
71
113
|
* Configures the `Access-Control-Allow-Headers` header for preflight requests.
|
|
72
114
|
* Falls back to the request's `Access-Control-Request-Headers` if not set.
|
|
73
|
-
*
|
|
74
|
-
* @default undefined
|
|
75
115
|
*/
|
|
76
116
|
allowHeaders?: readonly string[];
|
|
77
117
|
/**
|
|
78
118
|
* Configures the `Access-Control-Max-Age` header (in seconds) for preflight requests.
|
|
79
|
-
*
|
|
80
|
-
* @default undefined
|
|
81
119
|
*/
|
|
82
120
|
maxAge?: number;
|
|
83
121
|
/**
|
|
84
122
|
* Configures the `Access-Control-Allow-Credentials` header.
|
|
85
|
-
*
|
|
86
|
-
* @default undefined
|
|
87
123
|
*/
|
|
88
124
|
credentials?: boolean;
|
|
89
125
|
/**
|
|
90
126
|
* Configures the `Access-Control-Expose-Headers` header.
|
|
91
|
-
*
|
|
92
|
-
* @default undefined
|
|
93
127
|
*/
|
|
94
128
|
exposeHeaders?: readonly string[];
|
|
95
129
|
}
|
|
96
130
|
/**
|
|
97
|
-
*
|
|
131
|
+
* Configures the [CORS Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
|
132
|
+
* for your API, including preflight requests.
|
|
98
133
|
*
|
|
99
|
-
* @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin
|
|
134
|
+
* @see {@link https://orpc.dev/docs/plugins/cors | CORS Handler Plugin}
|
|
100
135
|
*/
|
|
101
136
|
declare class CORSHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
102
137
|
private readonly options;
|
|
@@ -112,17 +147,83 @@ declare class CORSHandlerPlugin<T extends Context> implements StandardHandlerPlu
|
|
|
112
147
|
}
|
|
113
148
|
|
|
114
149
|
/**
|
|
115
|
-
* Adds
|
|
116
|
-
*
|
|
117
|
-
*
|
|
150
|
+
* Adds Cross-Site Request Forgery (CSRF) protection that makes the safe `GET` method as
|
|
151
|
+
* secure as unsafe ones such as `POST`. It rejects `GET` requests arriving as top-level
|
|
152
|
+
* navigations initiated cross-site or from outside the browser, the only context where
|
|
153
|
+
* another site can make a browser attach `SameSite=Lax` cookies to a safe-method request.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* **Note**: Requests browsers send without `SameSite=Lax` cookies, such as cross-site `fetch`
|
|
157
|
+
* and `<img>`, pass through, so procedures stay reachable from other sites. This safeguard
|
|
158
|
+
* requires authentication cookies explicitly marked `SameSite=Lax` or `SameSite=Strict`,
|
|
159
|
+
* since browsers may attach other cookies to the requests that pass.
|
|
118
160
|
*
|
|
119
|
-
* @
|
|
161
|
+
* @see {@link https://orpc.dev/docs/plugins/get-method-csrf-protection | GET Method CSRF Protection Plugin}
|
|
120
162
|
*/
|
|
121
|
-
declare class
|
|
163
|
+
declare class GetMethodCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
122
164
|
name: string;
|
|
165
|
+
/** Judge the real request, before batch splits it into client-authored sub-requests. */
|
|
166
|
+
after: string[];
|
|
123
167
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
168
|
+
private isAllowed;
|
|
124
169
|
}
|
|
125
170
|
|
|
171
|
+
interface MethodOverrideHandlerPluginOptions {
|
|
172
|
+
/**
|
|
173
|
+
* The query parameter carrying the override method.
|
|
174
|
+
*
|
|
175
|
+
* @default 'method'
|
|
176
|
+
*/
|
|
177
|
+
param?: string;
|
|
178
|
+
/**
|
|
179
|
+
* The methods a POST request may be overridden to.
|
|
180
|
+
*
|
|
181
|
+
* GET and HEAD are excluded by default because they switch input decoding
|
|
182
|
+
* from the request body to the query string and widen the CSRF surface.
|
|
183
|
+
*
|
|
184
|
+
* @default ['PUT', 'PATCH', 'DELETE']
|
|
185
|
+
*/
|
|
186
|
+
methods?: readonly StandardMethod[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Overrides the HTTP method of a POST request based on a query parameter,
|
|
190
|
+
* so HTML forms (which only support GET and POST) can invoke procedures
|
|
191
|
+
* routed as PUT, PATCH, or DELETE.
|
|
192
|
+
*
|
|
193
|
+
* @see {@link https://orpc.dev/docs/plugins/method-override | Method Override Plugin}
|
|
194
|
+
*/
|
|
195
|
+
declare class MethodOverrideHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
196
|
+
name: string;
|
|
197
|
+
/**
|
|
198
|
+
* Should override batch sub-request methods, not the original batch request.
|
|
199
|
+
*/
|
|
200
|
+
before: string[];
|
|
201
|
+
private readonly param;
|
|
202
|
+
private readonly methods;
|
|
203
|
+
constructor(options?: MethodOverrideHandlerPluginOptions);
|
|
204
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Decompresses incoming request bodies based on the Content-Encoding header,
|
|
209
|
+
* supporting gzip, deflate, and deflate-raw.
|
|
210
|
+
*
|
|
211
|
+
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
212
|
+
*/
|
|
213
|
+
declare class RequestCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
214
|
+
name: string;
|
|
215
|
+
/**
|
|
216
|
+
* Should decompress the original batch request body instead of sub-requests.
|
|
217
|
+
*/
|
|
218
|
+
after: string[];
|
|
219
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The context shape into which the Request Headers Plugin injects `reqHeaders`.
|
|
224
|
+
*
|
|
225
|
+
* @see {@link https://orpc.dev/docs/plugins/request-headers | Request Headers Plugin}
|
|
226
|
+
*/
|
|
126
227
|
interface RequestHeadersHandlerPluginContext {
|
|
127
228
|
/**
|
|
128
229
|
* Request headers as a Headers instance. This is injected by the Request Headers Plugin.
|
|
@@ -133,13 +234,55 @@ interface RequestHeadersHandlerPluginContext {
|
|
|
133
234
|
* The Request Headers Plugin injects a `reqHeaders` instance into the context,
|
|
134
235
|
* allowing access to request headers in oRPC.
|
|
135
236
|
*
|
|
136
|
-
* @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin
|
|
237
|
+
* @see {@link https://orpc.dev/docs/plugins/request-headers | Request Headers Plugin}
|
|
137
238
|
*/
|
|
138
239
|
declare class RequestHeadersHandlerPlugin<T extends RequestHeadersHandlerPluginContext> implements StandardHandlerPlugin<T> {
|
|
139
240
|
name: string;
|
|
140
241
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
141
242
|
}
|
|
142
243
|
|
|
244
|
+
interface ResponseCompressionHandlerPluginOptions<_T extends Context> {
|
|
245
|
+
/**
|
|
246
|
+
* The compression schemes to use for response compression.
|
|
247
|
+
* Schemes are prioritized by their order in this array and
|
|
248
|
+
* only applied if the client supports them (via Accept-Encoding).
|
|
249
|
+
*
|
|
250
|
+
* @default ['gzip', 'deflate']
|
|
251
|
+
*/
|
|
252
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
253
|
+
/**
|
|
254
|
+
* The minimum response size in bytes required to trigger compression.
|
|
255
|
+
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
256
|
+
* If the response size cannot be determined, compression will still be applied.
|
|
257
|
+
*
|
|
258
|
+
* @default 1024 (1KB)
|
|
259
|
+
*/
|
|
260
|
+
threshold?: number;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Compresses response bodies based on the client's Accept-Encoding header.
|
|
264
|
+
* Works at the standard handler level, so it supports all adapters.
|
|
265
|
+
*
|
|
266
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
267
|
+
*/
|
|
268
|
+
declare class ResponseCompressionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
269
|
+
name: string;
|
|
270
|
+
/**
|
|
271
|
+
* Compression should be done after batching, to compress the final response.
|
|
272
|
+
* Compression should also be done after response headers are set, to access final headers like Content-Type and Cache-Control.
|
|
273
|
+
*/
|
|
274
|
+
after: string[];
|
|
275
|
+
private readonly encodings;
|
|
276
|
+
private readonly threshold;
|
|
277
|
+
constructor(options?: ResponseCompressionHandlerPluginOptions<T>);
|
|
278
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The context shape into which the Response Headers Plugin injects `resHeaders`.
|
|
283
|
+
*
|
|
284
|
+
* @see {@link https://orpc.dev/docs/plugins/response-headers | Response Headers Plugin}
|
|
285
|
+
*/
|
|
143
286
|
interface ResponseHeadersHandlerPluginContext {
|
|
144
287
|
/**
|
|
145
288
|
* Response headers as a Headers instance. This is injected by the Response Headers Plugin.
|
|
@@ -151,7 +294,7 @@ interface ResponseHeadersHandlerPluginContext {
|
|
|
151
294
|
* The Response Headers Plugin allows you to set response headers in oRPC.
|
|
152
295
|
* It injects a resHeaders instance into the context, enabling you to modify response headers easily.
|
|
153
296
|
*
|
|
154
|
-
* @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin
|
|
297
|
+
* @see {@link https://orpc.dev/docs/plugins/response-headers | Response Headers Plugin}
|
|
155
298
|
*/
|
|
156
299
|
declare class ResponseHeadersHandlerPlugin<T extends ResponseHeadersHandlerPluginContext> implements StandardHandlerPlugin<T> {
|
|
157
300
|
name: string;
|
|
@@ -162,5 +305,71 @@ declare class ResponseHeadersHandlerPlugin<T extends ResponseHeadersHandlerPlugi
|
|
|
162
305
|
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
163
306
|
}
|
|
164
307
|
|
|
165
|
-
|
|
166
|
-
|
|
308
|
+
interface RethrowHandlerPluginOptions<T extends Context> {
|
|
309
|
+
/**
|
|
310
|
+
* Decide which errors should be rethrown.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* const rethrowPlugin = new RethrowHandlerPlugin({
|
|
315
|
+
* filter: (error) => {
|
|
316
|
+
* // Rethrow all non-ORPCError errors
|
|
317
|
+
* return !(error instanceof ORPCError)
|
|
318
|
+
* }
|
|
319
|
+
* })
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
filter: (error: ThrowableError, options: StandardHandlerInterceptorOptions<T>) => boolean;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* The plugin can bypass oRPC's built-in error handling
|
|
326
|
+
* and rethrow matching errors directly to your framework's error handling mechanism
|
|
327
|
+
* (e.g., NestJS exception filters, Express error middleware).
|
|
328
|
+
*
|
|
329
|
+
* @see {@link https://orpc.dev/docs/plugins/rethrow | Rethrow Handler Plugin}
|
|
330
|
+
*/
|
|
331
|
+
declare class RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
332
|
+
name: string;
|
|
333
|
+
private readonly filter;
|
|
334
|
+
private readonly CONTEXT_SYMBOL;
|
|
335
|
+
constructor(options: RethrowHandlerPluginOptions<T>);
|
|
336
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
interface TimeoutHandlerPluginOptions<T extends Context> {
|
|
340
|
+
/**
|
|
341
|
+
* Timeout in milliseconds before the request signal is aborted.
|
|
342
|
+
* This only covers producing the response, use `streamingTimeout`
|
|
343
|
+
* to limit streaming response bodies.
|
|
344
|
+
* Use `null` or `undefined` to disable the timeout.
|
|
345
|
+
*/
|
|
346
|
+
timeout: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]>;
|
|
347
|
+
/**
|
|
348
|
+
* Timeout in milliseconds for the full duration of a streaming response body
|
|
349
|
+
* (async iterator object or readable stream), measured from when the response is produced.
|
|
350
|
+
* When exceeded, the request signal is aborted and the body ends
|
|
351
|
+
* once its producer honors the signal.
|
|
352
|
+
* Usually higher than `timeout`.
|
|
353
|
+
* Use `null` or `undefined` to disable the timeout.
|
|
354
|
+
*
|
|
355
|
+
* @default undefined (streaming responses run without limit)
|
|
356
|
+
*/
|
|
357
|
+
streamingTimeout?: Value<number | null | undefined, [options: StandardHandlerInterceptorOptions<T>]>;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* The Timeout Handler Plugin aborts the request signal with an `AbortError`
|
|
361
|
+
* when handling exceeds a configured timeout. It only aborts the signal,
|
|
362
|
+
* the procedure must honor it to stop early and produce the response.
|
|
363
|
+
*
|
|
364
|
+
* @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
|
|
365
|
+
*/
|
|
366
|
+
declare class TimeoutHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
367
|
+
private readonly timeout;
|
|
368
|
+
private readonly streamingTimeout;
|
|
369
|
+
name: string;
|
|
370
|
+
constructor(options: NoInfer<TimeoutHandlerPluginOptions<T>>);
|
|
371
|
+
init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export { BATCH_CONTENT_TYPE, BatchHandlerPlugin, CORSHandlerPlugin, CORSHandlerPlugin as CORSPlugin, GetMethodCsrfProtectionHandlerPlugin, MethodOverrideHandlerPlugin, RequestCompressionHandlerPlugin, RequestHeadersHandlerPlugin, RequestHeadersHandlerPlugin as RequestHeadersPlugin, ResponseCompressionHandlerPlugin, ResponseHeadersHandlerPlugin, ResponseHeadersHandlerPlugin as ResponseHeadersPlugin, RethrowHandlerPlugin, TimeoutHandlerPlugin };
|
|
375
|
+
export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, MethodOverrideHandlerPluginOptions, RequestHeadersHandlerPluginContext, RequestHeadersHandlerPluginContext as RequestHeadersPluginContext, ResponseCompressionHandlerPluginOptions, ResponseHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext as ResponseHeadersPluginContext, RethrowHandlerPluginOptions, TimeoutHandlerPluginOptions };
|