@orpc/server 2.0.0-beta.14 → 2.0.0-beta.16
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 +2 -2
- package/dist/adapters/crossws/index.d.mts +1 -1
- package/dist/adapters/crossws/index.d.ts +1 -1
- package/dist/adapters/crossws/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +5 -53
- package/dist/adapters/fetch/index.d.ts +5 -53
- package/dist/adapters/fetch/index.mjs +6 -136
- package/dist/adapters/message-port/index.d.mts +1 -1
- package/dist/adapters/message-port/index.d.ts +1 -1
- package/dist/adapters/message-port/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +4 -34
- package/dist/adapters/node/index.d.ts +4 -34
- package/dist/adapters/node/index.mjs +6 -112
- package/dist/adapters/standard/index.d.mts +1 -1
- package/dist/adapters/standard/index.d.ts +1 -1
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/websocket/index.d.mts +1 -1
- package/dist/adapters/websocket/index.d.ts +1 -1
- package/dist/adapters/websocket/index.mjs +3 -3
- package/dist/extensions/callable.mjs +2 -2
- package/dist/helpers/index.d.mts +3 -3
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/index.mjs +13 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +7 -7
- package/dist/plugins/index.d.mts +77 -2
- package/dist/plugins/index.d.ts +77 -2
- package/dist/plugins/index.mjs +305 -5
- package/dist/shared/{server.CrlKQucM.mjs → server.BDeup7Ky.mjs} +3 -3
- package/dist/shared/{server.CjOb6ItT.mjs → server.CUsS2s2p.mjs} +1 -1
- package/dist/shared/{server.BwHnWUuN.mjs → server.C_osSBcd.mjs} +1 -1
- package/dist/shared/{server.d_2NS3g5.d.ts → server.D0WUu0EH.d.ts} +3 -2
- package/dist/shared/{server.Cj5lgPuG.d.mts → server.D8cib80w.d.mts} +3 -2
- package/dist/shared/{server.GDpX6Df8.mjs → server.DZEvIn7o.mjs} +3 -3
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -107,7 +107,6 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
107
107
|
</tr>
|
|
108
108
|
<tr>
|
|
109
109
|
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
|
|
110
|
-
<td align="center"><a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&v=4" width="139" alt="Peter Adam"/><br />Peter Adam</a></td>
|
|
111
110
|
<td align="center"><a href="https://github.com/Ryanjso?ref=orpc" target="_blank" rel="noopener" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
112
111
|
<td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="139" alt="shota"/><br />shota</a></td>
|
|
113
112
|
</tr>
|
|
@@ -168,6 +167,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
168
167
|
<a href="https://github.com/nguyenlc1993?ref=orpc" target="_blank" rel="noopener" title="Lê Cao Nguyên"><img src="https://avatars.githubusercontent.com/u/13871971?u=83c8b69d9e35b589c4e1f066cc113b1d9461386f&v=4" width="32" height="32" alt="Lê Cao Nguyên" /></a>
|
|
169
168
|
<a href="https://github.com/wobsoriano?ref=orpc" target="_blank" rel="noopener" title="Robert Soriano"><img src="https://avatars.githubusercontent.com/u/13049130?u=6d72104182e7c9ed25934815313fb69107332111&v=4" width="32" height="32" alt="Robert Soriano" /></a>
|
|
170
169
|
<a href="https://github.com/SKostyukovich?ref=orpc" target="_blank" rel="noopener" title="SKostyukovich"><img src="https://avatars.githubusercontent.com/u/10700067?v=4" width="32" height="32" alt="SKostyukovich" /></a>
|
|
170
|
+
<a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&v=4" width="32" height="32" alt="Peter Adam" /></a>
|
|
171
171
|
<a href="https://github.com/FabworksHQ?ref=orpc" target="_blank" rel="noopener" title="Fabworks"><img src="https://avatars.githubusercontent.com/u/160179500?v=4" width="32" height="32" alt="Fabworks" /></a>
|
|
172
172
|
<a href="https://github.com/NovakAnton?ref=orpc" target="_blank" rel="noopener" title="Novak Antonijevic"><img src="https://avatars.githubusercontent.com/u/157126729?u=ae49fa22292d55c0434ff0ca008206155b18663b&v=4" width="32" height="32" alt="Novak Antonijevic" /></a>
|
|
173
173
|
<a href="https://github.com/laduniestu?ref=orpc" target="_blank" rel="noopener" title="Laduni Estu Syalwa"><img src="https://avatars.githubusercontent.com/u/44757637?u=a2fc1ea8f7d827a96721176f79d30592d1c48059&v=4" width="32" height="32" alt="Laduni Estu Syalwa" /></a>
|
|
@@ -175,7 +175,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
175
175
|
<a href="https://github.com/illarionvk?ref=orpc" target="_blank" rel="noopener" title="Illarion Koperski"><img src="https://avatars.githubusercontent.com/u/5012724?u=7cfa13652f7ac5fb3c56d880e3eb3fbe40c3ea34&v=4" width="32" height="32" alt="Illarion Koperski" /></a>
|
|
176
176
|
<a href="https://github.com/steelbrain?ref=orpc" target="_blank" rel="noopener" title="Anees Iqbal"><img src="https://avatars.githubusercontent.com/u/4278113?u=22b80b5399eed68ac76cd58b02961b0481f1db11&v=4" width="32" height="32" alt="Anees Iqbal" /></a>
|
|
177
177
|
<a href="https://github.com/Scrumplex?ref=orpc" target="_blank" rel="noopener" title="Sefa Eyeoglu"><img src="https://avatars.githubusercontent.com/u/11587657?u=ab503582165c0bbff0cca47ce31c9450bb1553c9&v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a>
|
|
178
|
-
<a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="
|
|
178
|
+
<a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="NΛTT"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&v=4" width="32" height="32" alt="NΛTT" /></a>
|
|
179
179
|
<a href="https://github.com/ChromeGG?ref=orpc" target="_blank" rel="noopener" title="Adam Tkaczyk"><img src="https://avatars.githubusercontent.com/u/39050595?u=a58ca6042a6950e94e6e92442db76ef584279bc0&v=4" width="32" height="32" alt="Adam Tkaczyk" /></a>
|
|
180
180
|
<a href="https://github.com/plancraft?ref=orpc" target="_blank" rel="noopener" title="plancraft"><img src="https://avatars.githubusercontent.com/u/46482287?v=4" width="32" height="32" alt="plancraft" /></a>
|
|
181
181
|
</p>
|
|
@@ -5,7 +5,7 @@ import { C as Context } from '../../shared/server.BL22TloH.mjs';
|
|
|
5
5
|
import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
|
|
6
6
|
import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
|
|
7
7
|
import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
|
|
8
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
8
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D8cib80w.mjs';
|
|
9
9
|
import '@orpc/client';
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standardserver/core';
|
|
@@ -5,7 +5,7 @@ import { C as Context } from '../../shared/server.BL22TloH.js';
|
|
|
5
5
|
import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
|
|
6
6
|
import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
|
|
7
7
|
import { R as Router } from '../../shared/server.Pa0F03f_.js';
|
|
8
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
8
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D0WUu0EH.js';
|
|
9
9
|
import '@orpc/client';
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standardserver/core';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standardserver/peer';
|
|
3
3
|
import { c as createStandardPeerRequestHandler } from '../../shared/server.CX4vUnDk.mjs';
|
|
4
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
4
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.DZEvIn7o.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@standardserver/core';
|
|
7
|
-
import '../../shared/server.
|
|
7
|
+
import '../../shared/server.BDeup7Ky.mjs';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/server.
|
|
9
|
+
import '../../shared/server.C_osSBcd.mjs';
|
|
10
10
|
|
|
11
11
|
class experimental_CrosswsHandler {
|
|
12
12
|
constructor(handler, options = {}) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as Context } from '../../shared/server.BL22TloH.mjs';
|
|
2
1
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
2
|
import { ToFetchResponseOptions } from '@standardserver/fetch';
|
|
3
|
+
import { C as Context } from '../../shared/server.BL22TloH.mjs';
|
|
4
4
|
import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
6
|
import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
|
|
7
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
7
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D8cib80w.mjs';
|
|
8
8
|
import '@orpc/client';
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standardserver/core';
|
|
@@ -53,7 +53,7 @@ interface FetchHandlerFetchInterceptorOptions<T extends Context> extends Standar
|
|
|
53
53
|
type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
|
|
54
54
|
interface FetchHandlerOptions<T extends Context> {
|
|
55
55
|
/**
|
|
56
|
-
* Options for how to convert the Fetch Response to a Standard Response, like event
|
|
56
|
+
* Options for how to convert the Fetch Response to a Standard Response, like event stream options, etc.
|
|
57
57
|
*/
|
|
58
58
|
toFetchResponse?: undefined | ToFetchResponseOptions;
|
|
59
59
|
/**
|
|
@@ -71,54 +71,6 @@ declare class FetchHandler<T extends Context> {
|
|
|
71
71
|
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FetchHandlerHandleResult>;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
|
|
75
|
-
interface BodyCompressionHandlerPluginOptions {
|
|
76
|
-
/**
|
|
77
|
-
* The compression schemes to use for response compression.
|
|
78
|
-
* Schemes are prioritized by their order in this array and
|
|
79
|
-
* only applied if the client supports them.
|
|
80
|
-
*
|
|
81
|
-
* @default ['gzip', 'deflate']
|
|
82
|
-
*/
|
|
83
|
-
encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
|
|
84
|
-
/**
|
|
85
|
-
* The minimum response size in bytes required to trigger compression.
|
|
86
|
-
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
87
|
-
* If the response size cannot be determined, compression will still be applied.
|
|
88
|
-
*
|
|
89
|
-
* @default 1024 (1KB)
|
|
90
|
-
*/
|
|
91
|
-
threshold?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
94
|
-
*
|
|
95
|
-
* @warning Event stream responses are never compressed, regardless of this filter's return value.
|
|
96
|
-
* @default only responses with compressible content types are compressed.
|
|
97
|
-
*/
|
|
98
|
-
filter?: (request: Request, response: Response) => boolean;
|
|
99
|
-
}
|
|
100
|
-
declare class BodyCompressionHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
101
|
-
name: string;
|
|
102
|
-
private readonly encodings;
|
|
103
|
-
private readonly threshold;
|
|
104
|
-
private readonly filter;
|
|
105
|
-
constructor(options?: BodyCompressionHandlerPluginOptions);
|
|
106
|
-
initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
interface BodyLimitHandlerPluginOptions {
|
|
110
|
-
/**
|
|
111
|
-
* The maximum size of the body in bytes.
|
|
112
|
-
*/
|
|
113
|
-
maxBodySize: number;
|
|
114
|
-
}
|
|
115
|
-
declare class BodyLimitHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
116
|
-
name: string;
|
|
117
|
-
private readonly maxBodySize;
|
|
118
|
-
constructor(options: BodyLimitHandlerPluginOptions);
|
|
119
|
-
initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
74
|
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
|
|
123
75
|
/**
|
|
124
76
|
* Configuration for {@link CSRFGuardHandlerPlugin}, which is enabled by default for `RPCHandler` over HTTP.
|
|
@@ -136,5 +88,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
|
136
88
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
137
89
|
}
|
|
138
90
|
|
|
139
|
-
export {
|
|
140
|
-
export type {
|
|
91
|
+
export { CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
|
92
|
+
export type { FetchHandlerFetchInterceptor, FetchHandlerFetchInterceptorOptions, FetchHandlerHandleResult, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as Context } from '../../shared/server.BL22TloH.js';
|
|
2
1
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
2
|
import { ToFetchResponseOptions } from '@standardserver/fetch';
|
|
3
|
+
import { C as Context } from '../../shared/server.BL22TloH.js';
|
|
4
4
|
import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
6
|
import { R as Router } from '../../shared/server.Pa0F03f_.js';
|
|
7
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
7
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D0WUu0EH.js';
|
|
8
8
|
import '@orpc/client';
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standardserver/core';
|
|
@@ -53,7 +53,7 @@ interface FetchHandlerFetchInterceptorOptions<T extends Context> extends Standar
|
|
|
53
53
|
type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
|
|
54
54
|
interface FetchHandlerOptions<T extends Context> {
|
|
55
55
|
/**
|
|
56
|
-
* Options for how to convert the Fetch Response to a Standard Response, like event
|
|
56
|
+
* Options for how to convert the Fetch Response to a Standard Response, like event stream options, etc.
|
|
57
57
|
*/
|
|
58
58
|
toFetchResponse?: undefined | ToFetchResponseOptions;
|
|
59
59
|
/**
|
|
@@ -71,54 +71,6 @@ declare class FetchHandler<T extends Context> {
|
|
|
71
71
|
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FetchHandlerHandleResult>;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
declare const ORDERED_SUPPORTED_ENCODINGS: readonly ["gzip", "deflate"];
|
|
75
|
-
interface BodyCompressionHandlerPluginOptions {
|
|
76
|
-
/**
|
|
77
|
-
* The compression schemes to use for response compression.
|
|
78
|
-
* Schemes are prioritized by their order in this array and
|
|
79
|
-
* only applied if the client supports them.
|
|
80
|
-
*
|
|
81
|
-
* @default ['gzip', 'deflate']
|
|
82
|
-
*/
|
|
83
|
-
encodings?: readonly (typeof ORDERED_SUPPORTED_ENCODINGS)[number][];
|
|
84
|
-
/**
|
|
85
|
-
* The minimum response size in bytes required to trigger compression.
|
|
86
|
-
* Responses smaller than this threshold will not be compressed to avoid overhead.
|
|
87
|
-
* If the response size cannot be determined, compression will still be applied.
|
|
88
|
-
*
|
|
89
|
-
* @default 1024 (1KB)
|
|
90
|
-
*/
|
|
91
|
-
threshold?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
94
|
-
*
|
|
95
|
-
* @warning Event stream responses are never compressed, regardless of this filter's return value.
|
|
96
|
-
* @default only responses with compressible content types are compressed.
|
|
97
|
-
*/
|
|
98
|
-
filter?: (request: Request, response: Response) => boolean;
|
|
99
|
-
}
|
|
100
|
-
declare class BodyCompressionHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
101
|
-
name: string;
|
|
102
|
-
private readonly encodings;
|
|
103
|
-
private readonly threshold;
|
|
104
|
-
private readonly filter;
|
|
105
|
-
constructor(options?: BodyCompressionHandlerPluginOptions);
|
|
106
|
-
initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
interface BodyLimitHandlerPluginOptions {
|
|
110
|
-
/**
|
|
111
|
-
* The maximum size of the body in bytes.
|
|
112
|
-
*/
|
|
113
|
-
maxBodySize: number;
|
|
114
|
-
}
|
|
115
|
-
declare class BodyLimitHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
116
|
-
name: string;
|
|
117
|
-
private readonly maxBodySize;
|
|
118
|
-
constructor(options: BodyLimitHandlerPluginOptions);
|
|
119
|
-
initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
74
|
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
|
|
123
75
|
/**
|
|
124
76
|
* Configuration for {@link CSRFGuardHandlerPlugin}, which is enabled by default for `RPCHandler` over HTTP.
|
|
@@ -136,5 +88,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
|
136
88
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
137
89
|
}
|
|
138
90
|
|
|
139
|
-
export {
|
|
140
|
-
export type {
|
|
91
|
+
export { CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
|
92
|
+
export type { FetchHandlerFetchInterceptor, FetchHandlerFetchInterceptorOptions, FetchHandlerHandleResult, FetchHandlerOptions, FetchHandlerPlugin, RPCHandlerOptions };
|
|
@@ -1,143 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ORPCError } from '@orpc/client';
|
|
1
|
+
import { sortPlugins, intercept, resolveMaybeOptionalOptions, toArray } from '@orpc/shared';
|
|
3
2
|
import { toStandardLazyRequest, toFetchResponse } from '@standardserver/fetch';
|
|
4
3
|
import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
|
|
5
4
|
import { C as CSRFGuardHandlerPlugin } from '../../shared/server.D_QauotT.mjs';
|
|
6
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
5
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.DZEvIn7o.mjs';
|
|
6
|
+
import '@orpc/client';
|
|
7
7
|
import '@standardserver/core';
|
|
8
|
-
import '../../shared/server.
|
|
8
|
+
import '../../shared/server.BDeup7Ky.mjs';
|
|
9
9
|
import '@orpc/contract';
|
|
10
|
-
import '../../shared/server.
|
|
11
|
-
|
|
12
|
-
const ORDERED_SUPPORTED_ENCODINGS = ["gzip", "deflate"];
|
|
13
|
-
class BodyCompressionHandlerPlugin {
|
|
14
|
-
name = "~body-compression";
|
|
15
|
-
encodings;
|
|
16
|
-
threshold;
|
|
17
|
-
filter;
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
this.encodings = options.encodings ?? ORDERED_SUPPORTED_ENCODINGS;
|
|
20
|
-
this.threshold = options.threshold ?? 1024;
|
|
21
|
-
this.filter = (request, response) => {
|
|
22
|
-
const hasContentDisposition = response.headers.has("content-disposition");
|
|
23
|
-
const contentType = response.headers.get("content-type");
|
|
24
|
-
if (!hasContentDisposition && contentType?.startsWith("text/event-stream")) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return options.filter ? options.filter(request, response) : isCompressibleContentType(contentType);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
initFetchHandlerOptions(options) {
|
|
31
|
-
return {
|
|
32
|
-
...options,
|
|
33
|
-
fetchInterceptors: [
|
|
34
|
-
async (interceptorOptions) => {
|
|
35
|
-
const result = await interceptorOptions.next();
|
|
36
|
-
if (!result.matched) {
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
const response = result.response;
|
|
40
|
-
if (response.headers.has("content-encoding") || response.headers.has("transfer-encoding") || isNoTransformCacheControl(response.headers.get("cache-control"))) {
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
const contentLength = response.headers.get("content-length");
|
|
44
|
-
if (contentLength && Number(contentLength) < this.threshold) {
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
const acceptEncoding = interceptorOptions.request.headers.get("accept-encoding")?.split(",").map((enc) => enc.trim().split(";")[0]);
|
|
48
|
-
const encoding = this.encodings.find((enc) => acceptEncoding?.includes(enc));
|
|
49
|
-
if (!response.body || encoding === void 0) {
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
if (!this.filter(interceptorOptions.request, response)) {
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
const compressedBody = response.body.pipeThrough(new CompressionStream(encoding));
|
|
56
|
-
const compressedHeaders = new Headers(response.headers);
|
|
57
|
-
compressedHeaders.delete("content-length");
|
|
58
|
-
compressedHeaders.set("content-encoding", encoding);
|
|
59
|
-
return {
|
|
60
|
-
...result,
|
|
61
|
-
response: new Response(compressedBody, {
|
|
62
|
-
status: response.status,
|
|
63
|
-
statusText: response.statusText,
|
|
64
|
-
headers: compressedHeaders
|
|
65
|
-
})
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
...toArray(options.fetchInterceptors)
|
|
69
|
-
]
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
74
|
-
function isCompressibleContentType(contentType) {
|
|
75
|
-
if (contentType === null) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return COMPRESSIBLE_CONTENT_TYPE_REGEX.test(contentType);
|
|
79
|
-
}
|
|
80
|
-
const CACHE_CONTROL_NO_TRANSFORM_REGEX = /(?:^|,)\s*no-transform\s*(?:,|$)/i;
|
|
81
|
-
function isNoTransformCacheControl(cacheControl) {
|
|
82
|
-
if (cacheControl === null) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return CACHE_CONTROL_NO_TRANSFORM_REGEX.test(cacheControl);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
class BodyLimitHandlerPlugin {
|
|
89
|
-
name = "~body-limit";
|
|
90
|
-
maxBodySize;
|
|
91
|
-
constructor(options) {
|
|
92
|
-
this.maxBodySize = options.maxBodySize;
|
|
93
|
-
}
|
|
94
|
-
initFetchHandlerOptions(options) {
|
|
95
|
-
return {
|
|
96
|
-
...options,
|
|
97
|
-
fetchInterceptors: [
|
|
98
|
-
async (interceptorOptions) => {
|
|
99
|
-
if (!interceptorOptions.request.body) {
|
|
100
|
-
return interceptorOptions.next();
|
|
101
|
-
}
|
|
102
|
-
let currentBodySize = 0;
|
|
103
|
-
const rawReader = interceptorOptions.request.body.getReader();
|
|
104
|
-
const body = new ReadableStream({
|
|
105
|
-
start: async (controller) => {
|
|
106
|
-
const reject = async (error) => {
|
|
107
|
-
controller.error(error);
|
|
108
|
-
await rawReader.cancel(error);
|
|
109
|
-
};
|
|
110
|
-
const contentLength = interceptorOptions.request.headers.get("content-length");
|
|
111
|
-
if (contentLength && Number(contentLength) > this.maxBodySize) {
|
|
112
|
-
await reject(new ORPCError("PAYLOAD_TOO_LARGE"));
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
while (true) {
|
|
116
|
-
const { done, value } = await rawReader.read();
|
|
117
|
-
if (done) {
|
|
118
|
-
controller.close();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
currentBodySize += value.length;
|
|
122
|
-
if (currentBodySize > this.maxBodySize) {
|
|
123
|
-
await reject(new ORPCError("PAYLOAD_TOO_LARGE"));
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
controller.enqueue(value);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
const requestInit = { body, duplex: "half" };
|
|
131
|
-
return interceptorOptions.next({
|
|
132
|
-
...interceptorOptions,
|
|
133
|
-
request: new Request(interceptorOptions.request, requestInit)
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
...toArray(options.fetchInterceptors)
|
|
137
|
-
]
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
10
|
+
import '../../shared/server.C_osSBcd.mjs';
|
|
141
11
|
|
|
142
12
|
class CompositeFetchHandlerPlugin {
|
|
143
13
|
name = "~composite/fetch-handler";
|
|
@@ -201,4 +71,4 @@ class RPCHandler extends FetchHandler {
|
|
|
201
71
|
}
|
|
202
72
|
}
|
|
203
73
|
|
|
204
|
-
export {
|
|
74
|
+
export { CompositeFetchHandlerPlugin, FetchHandler, RPCHandler };
|
|
@@ -5,7 +5,7 @@ import { C as Context } from '../../shared/server.BL22TloH.mjs';
|
|
|
5
5
|
import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
|
|
6
6
|
import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
|
|
7
7
|
import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
|
|
8
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
8
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D8cib80w.mjs';
|
|
9
9
|
import '@orpc/client';
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standardserver/core';
|
|
@@ -5,7 +5,7 @@ import { C as Context } from '../../shared/server.BL22TloH.js';
|
|
|
5
5
|
import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
|
|
6
6
|
import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
|
|
7
7
|
import { R as Router } from '../../shared/server.Pa0F03f_.js';
|
|
8
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
8
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D0WUu0EH.js';
|
|
9
9
|
import '@orpc/client';
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standardserver/core';
|
|
@@ -2,12 +2,12 @@ import { onMessagePortMessage, onMessagePortClose, postMessagePortMessage } from
|
|
|
2
2
|
import { value, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage, isPeerMessage } from '@standardserver/peer';
|
|
4
4
|
import { c as createStandardPeerRequestHandler } from '../../shared/server.CX4vUnDk.mjs';
|
|
5
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
5
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.DZEvIn7o.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@standardserver/core';
|
|
8
|
-
import '../../shared/server.
|
|
8
|
+
import '../../shared/server.BDeup7Ky.mjs';
|
|
9
9
|
import '@orpc/contract';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.C_osSBcd.mjs';
|
|
11
11
|
|
|
12
12
|
class MessagePortHandler {
|
|
13
13
|
constructor(handler, options = {}) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
1
2
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@standardserver/node';
|
|
2
3
|
import { C as Context } from '../../shared/server.BL22TloH.mjs';
|
|
3
|
-
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
|
-
import compression from '@orpc/interop/compression';
|
|
7
6
|
import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
|
|
8
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
7
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D8cib80w.mjs';
|
|
9
8
|
import '@orpc/client';
|
|
10
9
|
import '@orpc/contract';
|
|
11
10
|
import '@standardserver/core';
|
|
@@ -71,35 +70,6 @@ declare class NodeHttpHandler<T extends Context> {
|
|
|
71
70
|
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<NodeHttpHandlerHandleResult>;
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
interface BodyCompressionHandlerPluginOptions extends compression.CompressionOptions {
|
|
75
|
-
/**
|
|
76
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
77
|
-
*
|
|
78
|
-
* @warning Event stream responses are never compressed, regardless of this filter's return value.
|
|
79
|
-
* @default only responses with compressible content types are compressed.
|
|
80
|
-
*/
|
|
81
|
-
filter?: (request: NodeHttpRequest, response: NodeHttpResponse) => boolean;
|
|
82
|
-
}
|
|
83
|
-
declare class BodyCompressionHandlerPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
84
|
-
name: string;
|
|
85
|
-
private readonly compressionHandler;
|
|
86
|
-
constructor(options?: BodyCompressionHandlerPluginOptions);
|
|
87
|
-
initNodeHttpHandlerOptions(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
interface BodyLimitHandlerPluginOptions {
|
|
91
|
-
/**
|
|
92
|
-
* The maximum size of the body in bytes.
|
|
93
|
-
*/
|
|
94
|
-
maxBodySize: number;
|
|
95
|
-
}
|
|
96
|
-
declare class BodyLimitHandlerPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
97
|
-
name: string;
|
|
98
|
-
private readonly maxBodySize;
|
|
99
|
-
constructor(options: BodyLimitHandlerPluginOptions);
|
|
100
|
-
initNodeHttpHandlerOptions(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
73
|
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
|
|
104
74
|
/**
|
|
105
75
|
* Configuration for {@link CSRFGuardHandlerPlugin}, which is enabled by default for `RPCHandler` over HTTP.
|
|
@@ -117,5 +87,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
|
117
87
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
118
88
|
}
|
|
119
89
|
|
|
120
|
-
export {
|
|
121
|
-
export type {
|
|
90
|
+
export { CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
|
91
|
+
export type { NodeHttpHandlerHandleResult, NodeHttpHandlerNodeHttpInterceptor, NodeHttpHandlerNodeHttpInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
1
2
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@standardserver/node';
|
|
2
3
|
import { C as Context } from '../../shared/server.BL22TloH.js';
|
|
3
|
-
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
4
4
|
import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
|
-
import compression from '@orpc/interop/compression';
|
|
7
6
|
import { R as Router } from '../../shared/server.Pa0F03f_.js';
|
|
8
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
7
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.D0WUu0EH.js';
|
|
9
8
|
import '@orpc/client';
|
|
10
9
|
import '@orpc/contract';
|
|
11
10
|
import '@standardserver/core';
|
|
@@ -71,35 +70,6 @@ declare class NodeHttpHandler<T extends Context> {
|
|
|
71
70
|
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<NodeHttpHandlerHandleResult>;
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
interface BodyCompressionHandlerPluginOptions extends compression.CompressionOptions {
|
|
75
|
-
/**
|
|
76
|
-
* Override the default content-type filter used to determine which responses should be compressed.
|
|
77
|
-
*
|
|
78
|
-
* @warning Event stream responses are never compressed, regardless of this filter's return value.
|
|
79
|
-
* @default only responses with compressible content types are compressed.
|
|
80
|
-
*/
|
|
81
|
-
filter?: (request: NodeHttpRequest, response: NodeHttpResponse) => boolean;
|
|
82
|
-
}
|
|
83
|
-
declare class BodyCompressionHandlerPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
84
|
-
name: string;
|
|
85
|
-
private readonly compressionHandler;
|
|
86
|
-
constructor(options?: BodyCompressionHandlerPluginOptions);
|
|
87
|
-
initNodeHttpHandlerOptions(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
interface BodyLimitHandlerPluginOptions {
|
|
91
|
-
/**
|
|
92
|
-
* The maximum size of the body in bytes.
|
|
93
|
-
*/
|
|
94
|
-
maxBodySize: number;
|
|
95
|
-
}
|
|
96
|
-
declare class BodyLimitHandlerPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
97
|
-
name: string;
|
|
98
|
-
private readonly maxBodySize;
|
|
99
|
-
constructor(options: BodyLimitHandlerPluginOptions);
|
|
100
|
-
initNodeHttpHandlerOptions(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
73
|
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, Omit<StandardHandlerOptions<T>, 'plugins'>, RPCHandlerCodecOptions<T> {
|
|
104
74
|
/**
|
|
105
75
|
* Configuration for {@link CSRFGuardHandlerPlugin}, which is enabled by default for `RPCHandler` over HTTP.
|
|
@@ -117,5 +87,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
|
117
87
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
118
88
|
}
|
|
119
89
|
|
|
120
|
-
export {
|
|
121
|
-
export type {
|
|
90
|
+
export { CompositeNodeHttpHandlerPlugin, NodeHttpHandler, RPCHandler };
|
|
91
|
+
export type { NodeHttpHandlerHandleResult, NodeHttpHandlerNodeHttpInterceptor, NodeHttpHandlerNodeHttpInterceptorOptions, NodeHttpHandlerOptions, NodeHttpHandlerPlugin, RPCHandlerOptions };
|