@orpc/server 2.0.0-beta.35 → 2.0.0-beta.37
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 +29 -20
- package/dist/adapters/aws-lambda/index.d.mts +6 -49
- package/dist/adapters/aws-lambda/index.d.ts +6 -49
- package/dist/adapters/aws-lambda/index.mjs +13 -40
- package/dist/adapters/crossws/index.d.mts +2 -2
- package/dist/adapters/crossws/index.d.ts +2 -2
- package/dist/adapters/crossws/index.mjs +4 -3
- package/dist/adapters/fastify/index.d.mts +6 -49
- package/dist/adapters/fastify/index.d.ts +6 -49
- package/dist/adapters/fastify/index.mjs +13 -40
- package/dist/adapters/fetch/index.d.mts +7 -49
- package/dist/adapters/fetch/index.d.ts +7 -49
- package/dist/adapters/fetch/index.mjs +15 -41
- package/dist/adapters/message-port/index.d.mts +3 -3
- package/dist/adapters/message-port/index.d.ts +3 -3
- package/dist/adapters/message-port/index.mjs +4 -3
- package/dist/adapters/node/index.d.mts +7 -50
- package/dist/adapters/node/index.d.ts +7 -50
- package/dist/adapters/node/index.mjs +13 -40
- package/dist/adapters/standard/index.d.mts +91 -17
- package/dist/adapters/standard/index.d.ts +91 -17
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/standard-peer/index.d.mts +4 -9
- package/dist/adapters/standard-peer/index.d.ts +4 -9
- package/dist/adapters/standard-peer/index.mjs +10 -2
- package/dist/adapters/websocket/index.d.mts +3 -3
- package/dist/adapters/websocket/index.d.ts +3 -3
- package/dist/adapters/websocket/index.mjs +4 -3
- package/dist/index.mjs +4 -6
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/shared/{server.R0uHWfBo.d.mts → server.B5K1CViq.d.mts} +20 -9
- package/dist/shared/{server.BYnwk7Xz.mjs → server.BynNaBBA.mjs} +7 -9
- package/dist/shared/{server.sNWd6DAG.mjs → server.C0lFtoHU.mjs} +72 -11
- package/dist/shared/{server.CAiLRqPf.d.mts → server.C7xllBNN.d.mts} +1 -1
- package/dist/shared/server.CFqSIFnT.d.mts +14 -0
- package/dist/shared/{server.DEeCcNd6.d.ts → server.Cxranw-8.d.ts} +20 -9
- package/dist/shared/{server.b2-J4t6T.d.ts → server.D0dr-F8u.d.ts} +1 -1
- package/dist/shared/server.RRVK1xTV.d.ts +14 -0
- package/package.json +10 -10
- package/dist/shared/server.BGMO5dst.d.ts +0 -91
- package/dist/shared/server.CX4vUnDk.mjs +0 -11
- package/dist/shared/server.DcHlvZFK.d.mts +0 -91
|
@@ -1,57 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@standard-server/fastify';
|
|
3
3
|
import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
|
|
4
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
4
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.C0lFtoHU.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@standard-server/core';
|
|
7
7
|
import '../../shared/server.Djb_ebJT.mjs';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/server.
|
|
10
|
-
|
|
11
|
-
class CompositeFastifyHandlerPlugin {
|
|
12
|
-
name = "~composite/fastify";
|
|
13
|
-
plugins;
|
|
14
|
-
constructor(plugins = []) {
|
|
15
|
-
this.plugins = sortPlugins(plugins);
|
|
16
|
-
}
|
|
17
|
-
initFastifyHandlerOptions(options) {
|
|
18
|
-
for (const plugin of this.plugins) {
|
|
19
|
-
if (plugin.initFastifyHandlerOptions) {
|
|
20
|
-
options = plugin.initFastifyHandlerOptions(options);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
9
|
+
import '../../shared/server.BynNaBBA.mjs';
|
|
26
10
|
|
|
27
11
|
class FastifyHandler {
|
|
28
12
|
constructor(standardHandler, options = {}) {
|
|
29
13
|
this.standardHandler = standardHandler;
|
|
30
|
-
options = new CompositeFastifyHandlerPlugin(options.plugins).initFastifyHandlerOptions(options);
|
|
31
|
-
this.fastifyInterceptors = options.fastifyInterceptors;
|
|
32
14
|
this.sendStandardResponseOptions = options.sendStandardResponse;
|
|
33
15
|
}
|
|
34
16
|
sendStandardResponseOptions;
|
|
35
|
-
fastifyInterceptors;
|
|
36
17
|
async handle(request, reply, ...rest) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
request,
|
|
42
|
-
reply,
|
|
43
|
-
sendStandardResponseOptions: this.sendStandardResponseOptions
|
|
44
|
-
},
|
|
45
|
-
async ({ request: request2, reply: reply2, sendStandardResponseOptions, ...options }) => {
|
|
46
|
-
const standardRequest = toStandardLazyRequest(request2, reply2);
|
|
47
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
48
|
-
if (!result.matched) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
await sendStandardResponse(reply2, result.response, sendStandardResponseOptions);
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
18
|
+
const standardRequest = toStandardLazyRequest(request, reply);
|
|
19
|
+
const result = await this.standardHandler.handle(
|
|
20
|
+
standardRequest,
|
|
21
|
+
resolveFriendlyStandardHandlerHandleOptions(resolveMaybeOptionalOptions(rest))
|
|
54
22
|
);
|
|
23
|
+
if (!result.matched) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
await sendStandardResponse(reply, result.response, this.sendStandardResponseOptions);
|
|
27
|
+
return result;
|
|
55
28
|
}
|
|
56
29
|
}
|
|
57
30
|
|
|
@@ -63,4 +36,4 @@ class RPCHandler extends FastifyHandler {
|
|
|
63
36
|
}
|
|
64
37
|
}
|
|
65
38
|
|
|
66
|
-
export {
|
|
39
|
+
export { FastifyHandler, RPCHandler };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { R as BodyLimitPlugin } from '../../shared/server.
|
|
2
|
-
import {
|
|
1
|
+
export { R as BodyLimitPlugin } from '../../shared/server.C7xllBNN.mjs';
|
|
2
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ToFetchResponseOptions } from '@standard-server/fetch';
|
|
4
4
|
import { Context } from '../../index.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
6
6
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
7
7
|
import { Router } from '../../index.mjs';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
@@ -10,36 +10,6 @@ import '@orpc/client';
|
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standard-server/core';
|
|
12
12
|
|
|
13
|
-
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
14
|
-
/**
|
|
15
|
-
* Initializes the plugin and returns new fetch handler options.
|
|
16
|
-
* Called once per plugin instance during composition.
|
|
17
|
-
*
|
|
18
|
-
* This method allows plugins to wrap, extend, or transform fetch handler options
|
|
19
|
-
* such as fetch interceptors, or fetch configuration.
|
|
20
|
-
*
|
|
21
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
22
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* initFetchHandlerOptions(options) {
|
|
27
|
-
* return {
|
|
28
|
-
* ...options,
|
|
29
|
-
* interceptors: [...(options.interceptors || []), myInterceptor]
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
initFetchHandlerOptions?(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
35
|
-
}
|
|
36
|
-
declare class CompositeFetchHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
37
|
-
readonly name = "~composite/fetch";
|
|
38
|
-
protected readonly plugins: FetchHandlerPlugin<T>[];
|
|
39
|
-
constructor(plugins?: FetchHandlerPlugin<T>[]);
|
|
40
|
-
initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
13
|
type FetchHandlerHandleResult = {
|
|
44
14
|
matched: true;
|
|
45
15
|
response: Response;
|
|
@@ -47,32 +17,20 @@ type FetchHandlerHandleResult = {
|
|
|
47
17
|
matched: false;
|
|
48
18
|
response?: undefined;
|
|
49
19
|
};
|
|
50
|
-
interface
|
|
51
|
-
request: Request;
|
|
52
|
-
toFetchResponseOptions: ToFetchResponseOptions | undefined;
|
|
53
|
-
}
|
|
54
|
-
type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
|
|
55
|
-
interface FetchHandlerOptions<T extends Context> {
|
|
20
|
+
interface FetchHandlerOptions<_T extends Context> {
|
|
56
21
|
/**
|
|
57
22
|
* Options for how to convert the Fetch Response to a Standard Response, like event stream options, etc.
|
|
58
23
|
*/
|
|
59
24
|
toFetchResponse?: undefined | ToFetchResponseOptions;
|
|
60
|
-
/**
|
|
61
|
-
* Interceptors that run before the mapping between the Standard API and Fetch API,
|
|
62
|
-
* useful for customizing the mapping behavior (e.g. extending the body parser).
|
|
63
|
-
*/
|
|
64
|
-
fetchInterceptors?: FetchHandlerFetchInterceptor<T>[] | undefined;
|
|
65
|
-
plugins?: FetchHandlerPlugin<T>[] | undefined;
|
|
66
25
|
}
|
|
67
26
|
declare class FetchHandler<T extends Context> {
|
|
68
27
|
private readonly standardHandler;
|
|
69
28
|
private readonly toFetchResponseOptions;
|
|
70
|
-
private readonly fetchInterceptors;
|
|
71
29
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
|
72
30
|
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FetchHandlerHandleResult>;
|
|
73
31
|
}
|
|
74
32
|
|
|
75
|
-
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>,
|
|
33
|
+
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
76
34
|
}
|
|
77
35
|
/**
|
|
78
36
|
* Serves an oRPC router over the RPC protocol using the Fetch API
|
|
@@ -85,5 +43,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
|
85
43
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
86
44
|
}
|
|
87
45
|
|
|
88
|
-
export {
|
|
89
|
-
export type {
|
|
46
|
+
export { FetchHandler, RPCHandler };
|
|
47
|
+
export type { FetchHandlerHandleResult, FetchHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { R as BodyLimitPlugin } from '../../shared/server.
|
|
2
|
-
import {
|
|
1
|
+
export { R as BodyLimitPlugin } from '../../shared/server.D0dr-F8u.js';
|
|
2
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ToFetchResponseOptions } from '@standard-server/fetch';
|
|
4
4
|
import { Context } from '../../index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
6
6
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
7
7
|
import { Router } from '../../index.js';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
@@ -10,36 +10,6 @@ import '@orpc/client';
|
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standard-server/core';
|
|
12
12
|
|
|
13
|
-
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
14
|
-
/**
|
|
15
|
-
* Initializes the plugin and returns new fetch handler options.
|
|
16
|
-
* Called once per plugin instance during composition.
|
|
17
|
-
*
|
|
18
|
-
* This method allows plugins to wrap, extend, or transform fetch handler options
|
|
19
|
-
* such as fetch interceptors, or fetch configuration.
|
|
20
|
-
*
|
|
21
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
22
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* initFetchHandlerOptions(options) {
|
|
27
|
-
* return {
|
|
28
|
-
* ...options,
|
|
29
|
-
* interceptors: [...(options.interceptors || []), myInterceptor]
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
initFetchHandlerOptions?(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
35
|
-
}
|
|
36
|
-
declare class CompositeFetchHandlerPlugin<T extends Context> implements FetchHandlerPlugin<T> {
|
|
37
|
-
readonly name = "~composite/fetch";
|
|
38
|
-
protected readonly plugins: FetchHandlerPlugin<T>[];
|
|
39
|
-
constructor(plugins?: FetchHandlerPlugin<T>[]);
|
|
40
|
-
initFetchHandlerOptions(options: FetchHandlerOptions<T>): FetchHandlerOptions<T>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
13
|
type FetchHandlerHandleResult = {
|
|
44
14
|
matched: true;
|
|
45
15
|
response: Response;
|
|
@@ -47,32 +17,20 @@ type FetchHandlerHandleResult = {
|
|
|
47
17
|
matched: false;
|
|
48
18
|
response?: undefined;
|
|
49
19
|
};
|
|
50
|
-
interface
|
|
51
|
-
request: Request;
|
|
52
|
-
toFetchResponseOptions: ToFetchResponseOptions | undefined;
|
|
53
|
-
}
|
|
54
|
-
type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
|
|
55
|
-
interface FetchHandlerOptions<T extends Context> {
|
|
20
|
+
interface FetchHandlerOptions<_T extends Context> {
|
|
56
21
|
/**
|
|
57
22
|
* Options for how to convert the Fetch Response to a Standard Response, like event stream options, etc.
|
|
58
23
|
*/
|
|
59
24
|
toFetchResponse?: undefined | ToFetchResponseOptions;
|
|
60
|
-
/**
|
|
61
|
-
* Interceptors that run before the mapping between the Standard API and Fetch API,
|
|
62
|
-
* useful for customizing the mapping behavior (e.g. extending the body parser).
|
|
63
|
-
*/
|
|
64
|
-
fetchInterceptors?: FetchHandlerFetchInterceptor<T>[] | undefined;
|
|
65
|
-
plugins?: FetchHandlerPlugin<T>[] | undefined;
|
|
66
25
|
}
|
|
67
26
|
declare class FetchHandler<T extends Context> {
|
|
68
27
|
private readonly standardHandler;
|
|
69
28
|
private readonly toFetchResponseOptions;
|
|
70
|
-
private readonly fetchInterceptors;
|
|
71
29
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FetchHandlerOptions<T>>);
|
|
72
30
|
handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FetchHandlerHandleResult>;
|
|
73
31
|
}
|
|
74
32
|
|
|
75
|
-
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>,
|
|
33
|
+
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
76
34
|
}
|
|
77
35
|
/**
|
|
78
36
|
* Serves an oRPC router over the RPC protocol using the Fetch API
|
|
@@ -85,5 +43,5 @@ declare class RPCHandler<T extends Context> extends FetchHandler<T> {
|
|
|
85
43
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
86
44
|
}
|
|
87
45
|
|
|
88
|
-
export {
|
|
89
|
-
export type {
|
|
46
|
+
export { FetchHandler, RPCHandler };
|
|
47
|
+
export type { FetchHandlerHandleResult, FetchHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,59 +1,33 @@
|
|
|
1
1
|
export { R as BodyLimitPlugin } from '../../shared/server.1ExWFMze.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { toStandardLazyRequest, toFetchResponse } from '@standard-server/fetch';
|
|
4
4
|
import { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
|
|
5
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
5
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.C0lFtoHU.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '../../shared/server.Djb_ebJT.mjs';
|
|
9
9
|
import '@orpc/contract';
|
|
10
|
-
import '../../shared/server.
|
|
11
|
-
|
|
12
|
-
class CompositeFetchHandlerPlugin {
|
|
13
|
-
name = "~composite/fetch";
|
|
14
|
-
plugins;
|
|
15
|
-
constructor(plugins = []) {
|
|
16
|
-
this.plugins = sortPlugins(plugins);
|
|
17
|
-
}
|
|
18
|
-
initFetchHandlerOptions(options) {
|
|
19
|
-
for (const plugin of this.plugins) {
|
|
20
|
-
if (plugin.initFetchHandlerOptions) {
|
|
21
|
-
options = plugin.initFetchHandlerOptions(options);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return options;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
10
|
+
import '../../shared/server.BynNaBBA.mjs';
|
|
27
11
|
|
|
28
12
|
class FetchHandler {
|
|
29
13
|
constructor(standardHandler, options = {}) {
|
|
30
14
|
this.standardHandler = standardHandler;
|
|
31
|
-
options = new CompositeFetchHandlerPlugin(options.plugins).initFetchHandlerOptions(options);
|
|
32
|
-
this.fetchInterceptors = options.fetchInterceptors;
|
|
33
15
|
this.toFetchResponseOptions = options.toFetchResponse;
|
|
34
16
|
}
|
|
35
17
|
toFetchResponseOptions;
|
|
36
|
-
fetchInterceptors;
|
|
37
18
|
async handle(request, ...rest) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
request,
|
|
43
|
-
toFetchResponseOptions: this.toFetchResponseOptions
|
|
44
|
-
},
|
|
45
|
-
async ({ request: request2, toFetchResponseOptions, ...options }) => {
|
|
46
|
-
const standardRequest = toStandardLazyRequest(request2);
|
|
47
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
48
|
-
if (!result.matched) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
matched: true,
|
|
53
|
-
response: toFetchResponse(result.response, toFetchResponseOptions)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
19
|
+
const standardRequest = toStandardLazyRequest(request);
|
|
20
|
+
const result = await this.standardHandler.handle(
|
|
21
|
+
standardRequest,
|
|
22
|
+
resolveFriendlyStandardHandlerHandleOptions(resolveMaybeOptionalOptions(rest))
|
|
56
23
|
);
|
|
24
|
+
if (!result.matched) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
matched: true,
|
|
29
|
+
response: toFetchResponse(result.response, this.toFetchResponseOptions)
|
|
30
|
+
};
|
|
57
31
|
}
|
|
58
32
|
}
|
|
59
33
|
|
|
@@ -65,4 +39,4 @@ class RPCHandler extends FetchHandler {
|
|
|
65
39
|
}
|
|
66
40
|
}
|
|
67
41
|
|
|
68
|
-
export {
|
|
42
|
+
export { FetchHandler, RPCHandler };
|
|
@@ -3,7 +3,7 @@ import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
3
3
|
import { ServerPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
4
4
|
import { Context } from '../../index.mjs';
|
|
5
5
|
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
7
7
|
import { Router } from '../../index.mjs';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
9
9
|
import '@orpc/client';
|
|
@@ -44,13 +44,13 @@ declare class MessagePortHandler<T extends Context> {
|
|
|
44
44
|
*
|
|
45
45
|
* Prefer this over calling `.message()` and `.close()` manually.
|
|
46
46
|
*/
|
|
47
|
-
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<
|
|
47
|
+
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): void;
|
|
48
48
|
/**
|
|
49
49
|
* Handles a single message received from a message port.
|
|
50
50
|
*
|
|
51
51
|
* @param port The message port instance. Use the same instance for all messages.
|
|
52
52
|
*/
|
|
53
|
-
message(port: SupportedMessagePort, data: unknown, ...rest: MaybeOptionalOptions<
|
|
53
|
+
message(port: SupportedMessagePort, data: unknown, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<{
|
|
54
54
|
matched: boolean;
|
|
55
55
|
}>;
|
|
56
56
|
/**
|
|
@@ -3,7 +3,7 @@ import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
|
|
3
3
|
import { ServerPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
4
4
|
import { Context } from '../../index.js';
|
|
5
5
|
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
7
7
|
import { Router } from '../../index.js';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
9
9
|
import '@orpc/client';
|
|
@@ -44,13 +44,13 @@ declare class MessagePortHandler<T extends Context> {
|
|
|
44
44
|
*
|
|
45
45
|
* Prefer this over calling `.message()` and `.close()` manually.
|
|
46
46
|
*/
|
|
47
|
-
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<
|
|
47
|
+
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): void;
|
|
48
48
|
/**
|
|
49
49
|
* Handles a single message received from a message port.
|
|
50
50
|
*
|
|
51
51
|
* @param port The message port instance. Use the same instance for all messages.
|
|
52
52
|
*/
|
|
53
|
-
message(port: SupportedMessagePort, data: unknown, ...rest: MaybeOptionalOptions<
|
|
53
|
+
message(port: SupportedMessagePort, data: unknown, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<{
|
|
54
54
|
matched: boolean;
|
|
55
55
|
}>;
|
|
56
56
|
/**
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { onMessagePortMessage, onMessagePortClose, postMessagePortMessage } from '@orpc/client/message-port';
|
|
2
2
|
import { value, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage, isPeerMessage } from '@standard-server/peer';
|
|
4
|
-
import {
|
|
5
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
4
|
+
import { createStandardPeerRequestHandler } from '../standard-peer/index.mjs';
|
|
5
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.C0lFtoHU.mjs';
|
|
6
|
+
import '../../shared/server.W91HSRkE.mjs';
|
|
6
7
|
import '@orpc/client';
|
|
7
8
|
import '@standard-server/core';
|
|
8
9
|
import '../../shared/server.Djb_ebJT.mjs';
|
|
9
10
|
import '@orpc/contract';
|
|
10
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.BynNaBBA.mjs';
|
|
11
12
|
|
|
12
13
|
class MessagePortHandler {
|
|
13
14
|
constructor(handler, options = {}) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { R as BodyLimitPlugin } from '../../shared/server.
|
|
2
|
-
import {
|
|
1
|
+
export { R as BodyLimitPlugin } from '../../shared/server.C7xllBNN.mjs';
|
|
2
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@standard-server/node';
|
|
4
4
|
import { Context } from '../../index.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
6
6
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
7
7
|
import { Router } from '../../index.mjs';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
@@ -10,68 +10,25 @@ import '@orpc/client';
|
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standard-server/core';
|
|
12
12
|
|
|
13
|
-
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
14
|
-
/**
|
|
15
|
-
* Initializes the plugin and returns new node HTTP handler options.
|
|
16
|
-
* Called once per plugin instance during composition.
|
|
17
|
-
*
|
|
18
|
-
* This method allows plugins to wrap, extend, or transform node HTTP handler options
|
|
19
|
-
* such as interceptors, or other configuration.
|
|
20
|
-
*
|
|
21
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
22
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* initNodeHttpHandlerOptions(options) {
|
|
27
|
-
* return {
|
|
28
|
-
* ...options,
|
|
29
|
-
* nodeHttpInterceptors: [...(options.nodeHttpInterceptors || []), myInterceptor]
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
initNodeHttpHandlerOptions?(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
35
|
-
}
|
|
36
|
-
declare class CompositeNodeHttpHandlerPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
37
|
-
readonly name = "~composite/node-http";
|
|
38
|
-
protected readonly plugins: NodeHttpHandlerPlugin<T>[];
|
|
39
|
-
constructor(plugins?: NodeHttpHandlerPlugin<T>[]);
|
|
40
|
-
initNodeHttpHandlerOptions(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
13
|
type NodeHttpHandlerHandleResult = {
|
|
44
14
|
matched: true;
|
|
45
15
|
} | {
|
|
46
16
|
matched: false;
|
|
47
17
|
};
|
|
48
|
-
interface
|
|
49
|
-
request: NodeHttpRequest;
|
|
50
|
-
response: NodeHttpResponse;
|
|
51
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
52
|
-
}
|
|
53
|
-
type NodeHttpHandlerNodeHttpInterceptor<T extends Context> = Interceptor<NodeHttpHandlerNodeHttpInterceptorOptions<T>, Promise<NodeHttpHandlerHandleResult>>;
|
|
54
|
-
interface NodeHttpHandlerOptions<T extends Context> {
|
|
18
|
+
interface NodeHttpHandlerOptions<_T extends Context> {
|
|
55
19
|
/**
|
|
56
20
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
57
21
|
*/
|
|
58
22
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* Interceptors that run before the mapping between the Standard API and Node HTTP API,
|
|
61
|
-
* useful for extending Node HTTP request/response before handling, ...
|
|
62
|
-
*/
|
|
63
|
-
nodeHttpInterceptors?: NodeHttpHandlerNodeHttpInterceptor<T>[] | undefined;
|
|
64
|
-
plugins?: NodeHttpHandlerPlugin<T>[] | undefined;
|
|
65
23
|
}
|
|
66
24
|
declare class NodeHttpHandler<T extends Context> {
|
|
67
25
|
private readonly standardHandler;
|
|
68
26
|
private readonly sendStandardResponseOptions;
|
|
69
|
-
private readonly nodeHttpInterceptors;
|
|
70
27
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>);
|
|
71
28
|
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<NodeHttpHandlerHandleResult>;
|
|
72
29
|
}
|
|
73
30
|
|
|
74
|
-
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>,
|
|
31
|
+
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
75
32
|
}
|
|
76
33
|
/**
|
|
77
34
|
* Serves an oRPC router over the RPC protocol using Node.js built-in
|
|
@@ -83,5 +40,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
|
83
40
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
84
41
|
}
|
|
85
42
|
|
|
86
|
-
export {
|
|
87
|
-
export type { NodeHttpHandlerHandleResult,
|
|
43
|
+
export { NodeHttpHandler, RPCHandler };
|
|
44
|
+
export type { NodeHttpHandlerHandleResult, NodeHttpHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { R as BodyLimitPlugin } from '../../shared/server.
|
|
2
|
-
import {
|
|
1
|
+
export { R as BodyLimitPlugin } from '../../shared/server.D0dr-F8u.js';
|
|
2
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@standard-server/node';
|
|
4
4
|
import { Context } from '../../index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
6
6
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
7
7
|
import { Router } from '../../index.js';
|
|
8
8
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
@@ -10,68 +10,25 @@ import '@orpc/client';
|
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '@standard-server/core';
|
|
12
12
|
|
|
13
|
-
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
14
|
-
/**
|
|
15
|
-
* Initializes the plugin and returns new node HTTP handler options.
|
|
16
|
-
* Called once per plugin instance during composition.
|
|
17
|
-
*
|
|
18
|
-
* This method allows plugins to wrap, extend, or transform node HTTP handler options
|
|
19
|
-
* such as interceptors, or other configuration.
|
|
20
|
-
*
|
|
21
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
22
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* initNodeHttpHandlerOptions(options) {
|
|
27
|
-
* return {
|
|
28
|
-
* ...options,
|
|
29
|
-
* nodeHttpInterceptors: [...(options.nodeHttpInterceptors || []), myInterceptor]
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
initNodeHttpHandlerOptions?(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
35
|
-
}
|
|
36
|
-
declare class CompositeNodeHttpHandlerPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
|
|
37
|
-
readonly name = "~composite/node-http";
|
|
38
|
-
protected readonly plugins: NodeHttpHandlerPlugin<T>[];
|
|
39
|
-
constructor(plugins?: NodeHttpHandlerPlugin<T>[]);
|
|
40
|
-
initNodeHttpHandlerOptions(options: NodeHttpHandlerOptions<T>): NodeHttpHandlerOptions<T>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
13
|
type NodeHttpHandlerHandleResult = {
|
|
44
14
|
matched: true;
|
|
45
15
|
} | {
|
|
46
16
|
matched: false;
|
|
47
17
|
};
|
|
48
|
-
interface
|
|
49
|
-
request: NodeHttpRequest;
|
|
50
|
-
response: NodeHttpResponse;
|
|
51
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
52
|
-
}
|
|
53
|
-
type NodeHttpHandlerNodeHttpInterceptor<T extends Context> = Interceptor<NodeHttpHandlerNodeHttpInterceptorOptions<T>, Promise<NodeHttpHandlerHandleResult>>;
|
|
54
|
-
interface NodeHttpHandlerOptions<T extends Context> {
|
|
18
|
+
interface NodeHttpHandlerOptions<_T extends Context> {
|
|
55
19
|
/**
|
|
56
20
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
57
21
|
*/
|
|
58
22
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* Interceptors that run before the mapping between the Standard API and Node HTTP API,
|
|
61
|
-
* useful for extending Node HTTP request/response before handling, ...
|
|
62
|
-
*/
|
|
63
|
-
nodeHttpInterceptors?: NodeHttpHandlerNodeHttpInterceptor<T>[] | undefined;
|
|
64
|
-
plugins?: NodeHttpHandlerPlugin<T>[] | undefined;
|
|
65
23
|
}
|
|
66
24
|
declare class NodeHttpHandler<T extends Context> {
|
|
67
25
|
private readonly standardHandler;
|
|
68
26
|
private readonly sendStandardResponseOptions;
|
|
69
|
-
private readonly nodeHttpInterceptors;
|
|
70
27
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<NodeHttpHandlerOptions<T>>);
|
|
71
28
|
handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<NodeHttpHandlerHandleResult>;
|
|
72
29
|
}
|
|
73
30
|
|
|
74
|
-
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>,
|
|
31
|
+
interface RPCHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
75
32
|
}
|
|
76
33
|
/**
|
|
77
34
|
* Serves an oRPC router over the RPC protocol using Node.js built-in
|
|
@@ -83,5 +40,5 @@ declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
|
|
|
83
40
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
84
41
|
}
|
|
85
42
|
|
|
86
|
-
export {
|
|
87
|
-
export type { NodeHttpHandlerHandleResult,
|
|
43
|
+
export { NodeHttpHandler, RPCHandler };
|
|
44
|
+
export type { NodeHttpHandlerHandleResult, NodeHttpHandlerOptions, RPCHandlerOptions };
|