@orpc/server 2.0.0-beta.36 → 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/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 +12 -39
- package/dist/adapters/crossws/index.mjs +1 -1
- package/dist/adapters/fastify/index.d.mts +6 -49
- package/dist/adapters/fastify/index.d.ts +6 -49
- package/dist/adapters/fastify/index.mjs +12 -39
- package/dist/adapters/fetch/index.d.mts +6 -48
- package/dist/adapters/fetch/index.d.ts +6 -48
- package/dist/adapters/fetch/index.mjs +14 -40
- package/dist/adapters/message-port/index.mjs +1 -1
- package/dist/adapters/node/index.d.mts +6 -49
- package/dist/adapters/node/index.d.ts +6 -49
- package/dist/adapters/node/index.mjs +12 -39
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/adapters/websocket/index.mjs +1 -1
- package/dist/shared/{server.vUIzQiOP.mjs → server.C0lFtoHU.mjs} +57 -57
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyAPIGatewayProxyEvent, HttpResponseStream } from '@standard-server/aws-lambda';
|
|
3
3
|
import { Context } from '../../index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
6
|
import { Router } from '../../index.mjs';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
@@ -9,58 +9,16 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface AwsLambdaHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new AWS Lambda handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform AWS Lambda handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initAwsLambdaHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* awsLambdaInterceptors: [...(options.awsLambdaInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initAwsLambdaHandlerOptions?(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeAwsLambdaHandlerPlugin<T extends Context> implements AwsLambdaHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/aws-lambda";
|
|
37
|
-
protected readonly plugins: AwsLambdaHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: AwsLambdaHandlerPlugin<T>[]);
|
|
39
|
-
initAwsLambdaHandlerOptions(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type AwsLambdaHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
event: AnyAPIGatewayProxyEvent;
|
|
49
|
-
responseStream: HttpResponseStream;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type AwsLambdaHandlerAwsLambdaInterceptor<T extends Context> = Interceptor<AwsLambdaHandlerAwsLambdaInterceptorOptions<T>, Promise<AwsLambdaHandlerHandleResult>>;
|
|
53
|
-
interface AwsLambdaHandlerOptions<T extends Context> {
|
|
17
|
+
interface AwsLambdaHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and AWS Lambda API,
|
|
60
|
-
* useful for extending the AWS Lambda event/response stream before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
awsLambdaInterceptors?: AwsLambdaHandlerAwsLambdaInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: AwsLambdaHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
/**
|
|
66
24
|
* Requires the AWS Lambda Node.js runtime with response streaming enabled,
|
|
@@ -69,12 +27,11 @@ interface AwsLambdaHandlerOptions<T extends Context> {
|
|
|
69
27
|
declare class AwsLambdaHandler<T extends Context> {
|
|
70
28
|
private readonly standardHandler;
|
|
71
29
|
private readonly sendStandardResponseOptions;
|
|
72
|
-
private readonly awsLambdaInterceptors;
|
|
73
30
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<AwsLambdaHandlerOptions<T>>);
|
|
74
31
|
handle(event: AnyAPIGatewayProxyEvent, responseStream: HttpResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<AwsLambdaHandlerHandleResult>;
|
|
75
32
|
}
|
|
76
33
|
|
|
77
|
-
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>,
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
78
35
|
}
|
|
79
36
|
/**
|
|
80
37
|
* Serves an oRPC router over the RPC protocol on AWS Lambda,
|
|
@@ -89,5 +46,5 @@ declare class RPCHandler<T extends Context> extends AwsLambdaHandler<T> {
|
|
|
89
46
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
90
47
|
}
|
|
91
48
|
|
|
92
|
-
export { AwsLambdaHandler,
|
|
93
|
-
export type {
|
|
49
|
+
export { AwsLambdaHandler, RPCHandler };
|
|
50
|
+
export type { AwsLambdaHandlerHandleResult, AwsLambdaHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyAPIGatewayProxyEvent, HttpResponseStream } from '@standard-server/aws-lambda';
|
|
3
3
|
import { Context } from '../../index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
6
|
import { Router } from '../../index.js';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
@@ -9,58 +9,16 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface AwsLambdaHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new AWS Lambda handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform AWS Lambda handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initAwsLambdaHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* awsLambdaInterceptors: [...(options.awsLambdaInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initAwsLambdaHandlerOptions?(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeAwsLambdaHandlerPlugin<T extends Context> implements AwsLambdaHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/aws-lambda";
|
|
37
|
-
protected readonly plugins: AwsLambdaHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: AwsLambdaHandlerPlugin<T>[]);
|
|
39
|
-
initAwsLambdaHandlerOptions(options: AwsLambdaHandlerOptions<T>): AwsLambdaHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type AwsLambdaHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
event: AnyAPIGatewayProxyEvent;
|
|
49
|
-
responseStream: HttpResponseStream;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type AwsLambdaHandlerAwsLambdaInterceptor<T extends Context> = Interceptor<AwsLambdaHandlerAwsLambdaInterceptorOptions<T>, Promise<AwsLambdaHandlerHandleResult>>;
|
|
53
|
-
interface AwsLambdaHandlerOptions<T extends Context> {
|
|
17
|
+
interface AwsLambdaHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and AWS Lambda API,
|
|
60
|
-
* useful for extending the AWS Lambda event/response stream before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
awsLambdaInterceptors?: AwsLambdaHandlerAwsLambdaInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: AwsLambdaHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
/**
|
|
66
24
|
* Requires the AWS Lambda Node.js runtime with response streaming enabled,
|
|
@@ -69,12 +27,11 @@ interface AwsLambdaHandlerOptions<T extends Context> {
|
|
|
69
27
|
declare class AwsLambdaHandler<T extends Context> {
|
|
70
28
|
private readonly standardHandler;
|
|
71
29
|
private readonly sendStandardResponseOptions;
|
|
72
|
-
private readonly awsLambdaInterceptors;
|
|
73
30
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<AwsLambdaHandlerOptions<T>>);
|
|
74
31
|
handle(event: AnyAPIGatewayProxyEvent, responseStream: HttpResponseStream, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<AwsLambdaHandlerHandleResult>;
|
|
75
32
|
}
|
|
76
33
|
|
|
77
|
-
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>,
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
78
35
|
}
|
|
79
36
|
/**
|
|
80
37
|
* Serves an oRPC router over the RPC protocol on AWS Lambda,
|
|
@@ -89,5 +46,5 @@ declare class RPCHandler<T extends Context> extends AwsLambdaHandler<T> {
|
|
|
89
46
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
90
47
|
}
|
|
91
48
|
|
|
92
|
-
export { AwsLambdaHandler,
|
|
93
|
-
export type {
|
|
49
|
+
export { AwsLambdaHandler, RPCHandler };
|
|
50
|
+
export type { AwsLambdaHandlerHandleResult, AwsLambdaHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,57 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@standard-server/aws-lambda';
|
|
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
9
|
import '../../shared/server.BynNaBBA.mjs';
|
|
10
10
|
|
|
11
|
-
class CompositeAwsLambdaHandlerPlugin {
|
|
12
|
-
name = "~composite/aws-lambda";
|
|
13
|
-
plugins;
|
|
14
|
-
constructor(plugins = []) {
|
|
15
|
-
this.plugins = sortPlugins(plugins);
|
|
16
|
-
}
|
|
17
|
-
initAwsLambdaHandlerOptions(options) {
|
|
18
|
-
for (const plugin of this.plugins) {
|
|
19
|
-
if (plugin.initAwsLambdaHandlerOptions) {
|
|
20
|
-
options = plugin.initAwsLambdaHandlerOptions(options);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
11
|
class AwsLambdaHandler {
|
|
28
12
|
constructor(standardHandler, options = {}) {
|
|
29
13
|
this.standardHandler = standardHandler;
|
|
30
|
-
options = new CompositeAwsLambdaHandlerPlugin(options.plugins).initAwsLambdaHandlerOptions(options);
|
|
31
|
-
this.awsLambdaInterceptors = options.awsLambdaInterceptors;
|
|
32
14
|
this.sendStandardResponseOptions = options.sendStandardResponse;
|
|
33
15
|
}
|
|
34
16
|
sendStandardResponseOptions;
|
|
35
|
-
awsLambdaInterceptors;
|
|
36
17
|
async handle(event, responseStream, ...rest) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
event,
|
|
42
|
-
responseStream,
|
|
43
|
-
sendStandardResponseOptions: this.sendStandardResponseOptions
|
|
44
|
-
},
|
|
45
|
-
async ({ event: event2, responseStream: responseStream2, sendStandardResponseOptions, ...options }) => {
|
|
46
|
-
const standardRequest = toStandardLazyRequest(event2, responseStream2);
|
|
47
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
48
|
-
if (!result.matched) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
await sendStandardResponse(responseStream2, result.response, sendStandardResponseOptions);
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
18
|
+
const standardRequest = toStandardLazyRequest(event, responseStream);
|
|
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(responseStream, result.response, this.sendStandardResponseOptions);
|
|
27
|
+
return result;
|
|
55
28
|
}
|
|
56
29
|
}
|
|
57
30
|
|
|
@@ -63,4 +36,4 @@ class RPCHandler extends AwsLambdaHandler {
|
|
|
63
36
|
}
|
|
64
37
|
}
|
|
65
38
|
|
|
66
|
-
export { AwsLambdaHandler,
|
|
39
|
+
export { AwsLambdaHandler, RPCHandler };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standard-server/peer';
|
|
3
3
|
import { createStandardPeerRequestHandler } from '../standard-peer/index.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 '../../shared/server.W91HSRkE.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@standard-server/core';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyFastifyRequest, AnyFastifyReply } from '@standard-server/fastify';
|
|
3
3
|
import { Context } from '../../index.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.mjs';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
|
|
6
6
|
import { Router } from '../../index.mjs';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.mjs';
|
|
@@ -9,68 +9,25 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface FastifyHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new Fastify handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform Fastify handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initFastifyHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* fastifyInterceptors: [...(options.fastifyInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initFastifyHandlerOptions?(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeFastifyHandlerPlugin<T extends Context> implements FastifyHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/fastify";
|
|
37
|
-
protected readonly plugins: FastifyHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: FastifyHandlerPlugin<T>[]);
|
|
39
|
-
initFastifyHandlerOptions(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type FastifyHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
request: AnyFastifyRequest;
|
|
49
|
-
reply: AnyFastifyReply;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type FastifyHandlerFastifyInterceptor<T extends Context> = Interceptor<FastifyHandlerFastifyInterceptorOptions<T>, Promise<FastifyHandlerHandleResult>>;
|
|
53
|
-
interface FastifyHandlerOptions<T extends Context> {
|
|
17
|
+
interface FastifyHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and Fastify API,
|
|
60
|
-
* useful for extending the Fastify request/reply before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
fastifyInterceptors?: FastifyHandlerFastifyInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: FastifyHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
declare class FastifyHandler<T extends Context> {
|
|
66
24
|
private readonly standardHandler;
|
|
67
25
|
private readonly sendStandardResponseOptions;
|
|
68
|
-
private readonly fastifyInterceptors;
|
|
69
26
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
70
27
|
handle(request: AnyFastifyRequest, reply: AnyFastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FastifyHandlerHandleResult>;
|
|
71
28
|
}
|
|
72
29
|
|
|
73
|
-
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>,
|
|
30
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
74
31
|
}
|
|
75
32
|
/**
|
|
76
33
|
* Serves an oRPC router over the RPC protocol inside a Fastify server.
|
|
@@ -81,5 +38,5 @@ declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
|
81
38
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
82
39
|
}
|
|
83
40
|
|
|
84
|
-
export {
|
|
85
|
-
export type {
|
|
41
|
+
export { FastifyHandler, RPCHandler };
|
|
42
|
+
export type { FastifyHandlerHandleResult, FastifyHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, AnyFastifyRequest, AnyFastifyReply } from '@standard-server/fastify';
|
|
3
3
|
import { Context } from '../../index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { StandardHandler, StandardHandlerOptions } from '../standard/index.js';
|
|
5
5
|
import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
|
|
6
6
|
import { Router } from '../../index.js';
|
|
7
7
|
import { RPCHandlerCodecOptions } from '../standard/index.js';
|
|
@@ -9,68 +9,25 @@ import '@orpc/client';
|
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standard-server/core';
|
|
11
11
|
|
|
12
|
-
interface FastifyHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the plugin and returns new Fastify handler options.
|
|
15
|
-
* Called once per plugin instance during composition.
|
|
16
|
-
*
|
|
17
|
-
* This method allows plugins to wrap, extend, or transform Fastify handler options
|
|
18
|
-
* such as interceptors, or other configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param options - The current handler options from previous plugins or base configuration
|
|
21
|
-
* @returns Transformed handler options with plugin's modifications applied
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* initFastifyHandlerOptions(options) {
|
|
26
|
-
* return {
|
|
27
|
-
* ...options,
|
|
28
|
-
* fastifyInterceptors: [...(options.fastifyInterceptors || []), myInterceptor]
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
initFastifyHandlerOptions?(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
34
|
-
}
|
|
35
|
-
declare class CompositeFastifyHandlerPlugin<T extends Context> implements FastifyHandlerPlugin<T> {
|
|
36
|
-
readonly name = "~composite/fastify";
|
|
37
|
-
protected readonly plugins: FastifyHandlerPlugin<T>[];
|
|
38
|
-
constructor(plugins?: FastifyHandlerPlugin<T>[]);
|
|
39
|
-
initFastifyHandlerOptions(options: FastifyHandlerOptions<T>): FastifyHandlerOptions<T>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
type FastifyHandlerHandleResult = {
|
|
43
13
|
matched: true;
|
|
44
14
|
} | {
|
|
45
15
|
matched: false;
|
|
46
16
|
};
|
|
47
|
-
interface
|
|
48
|
-
request: AnyFastifyRequest;
|
|
49
|
-
reply: AnyFastifyReply;
|
|
50
|
-
sendStandardResponseOptions: SendStandardResponseOptions | undefined;
|
|
51
|
-
}
|
|
52
|
-
type FastifyHandlerFastifyInterceptor<T extends Context> = Interceptor<FastifyHandlerFastifyInterceptorOptions<T>, Promise<FastifyHandlerHandleResult>>;
|
|
53
|
-
interface FastifyHandlerOptions<T extends Context> {
|
|
17
|
+
interface FastifyHandlerOptions<_T extends Context> {
|
|
54
18
|
/**
|
|
55
19
|
* Custom options for `sendStandardResponse`, used to send a `Standard Response`
|
|
56
20
|
*/
|
|
57
21
|
sendStandardResponse?: SendStandardResponseOptions | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Interceptors that run before the mapping between the Standard API and Fastify API,
|
|
60
|
-
* useful for extending the Fastify request/reply before handling, ...
|
|
61
|
-
*/
|
|
62
|
-
fastifyInterceptors?: FastifyHandlerFastifyInterceptor<T>[] | undefined;
|
|
63
|
-
plugins?: FastifyHandlerPlugin<T>[] | undefined;
|
|
64
22
|
}
|
|
65
23
|
declare class FastifyHandler<T extends Context> {
|
|
66
24
|
private readonly standardHandler;
|
|
67
25
|
private readonly sendStandardResponseOptions;
|
|
68
|
-
private readonly fastifyInterceptors;
|
|
69
26
|
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
70
27
|
handle(request: AnyFastifyRequest, reply: AnyFastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandlerHandleOptions<T>>): Promise<FastifyHandlerHandleResult>;
|
|
71
28
|
}
|
|
72
29
|
|
|
73
|
-
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>,
|
|
30
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, RPCHandlerCodecOptions<T> {
|
|
74
31
|
}
|
|
75
32
|
/**
|
|
76
33
|
* Serves an oRPC router over the RPC protocol inside a Fastify server.
|
|
@@ -81,5 +38,5 @@ declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
|
81
38
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
82
39
|
}
|
|
83
40
|
|
|
84
|
-
export {
|
|
85
|
-
export type {
|
|
41
|
+
export { FastifyHandler, RPCHandler };
|
|
42
|
+
export type { FastifyHandlerHandleResult, FastifyHandlerOptions, RPCHandlerOptions };
|
|
@@ -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
9
|
import '../../shared/server.BynNaBBA.mjs';
|
|
10
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
|
-
}
|
|
26
|
-
|
|
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
1
|
export { R as BodyLimitPlugin } from '../../shared/server.C7xllBNN.mjs';
|
|
2
|
-
import {
|
|
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
1
|
export { R as BodyLimitPlugin } from '../../shared/server.D0dr-F8u.js';
|
|
2
|
-
import {
|
|
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
10
|
import '../../shared/server.BynNaBBA.mjs';
|
|
11
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
|
-
}
|
|
27
|
-
|
|
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 };
|
|
@@ -2,7 +2,7 @@ import { onMessagePortMessage, onMessagePortClose, postMessagePortMessage } from
|
|
|
2
2
|
import { value, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage, isPeerMessage } from '@standard-server/peer';
|
|
4
4
|
import { createStandardPeerRequestHandler } from '../standard-peer/index.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 '../../shared/server.W91HSRkE.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@standard-server/core';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { R as BodyLimitPlugin } from '../../shared/server.C7xllBNN.mjs';
|
|
2
|
-
import {
|
|
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
1
|
export { R as BodyLimitPlugin } from '../../shared/server.D0dr-F8u.js';
|
|
2
|
-
import {
|
|
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 };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { R as BodyLimitPlugin } from '../../shared/server.1ExWFMze.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { toStandardLazyRequest, sendStandardResponse } from '@standard-server/node';
|
|
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 '@standard-server/fetch';
|
|
@@ -10,50 +10,23 @@ import '../../shared/server.Djb_ebJT.mjs';
|
|
|
10
10
|
import '@orpc/contract';
|
|
11
11
|
import '../../shared/server.BynNaBBA.mjs';
|
|
12
12
|
|
|
13
|
-
class CompositeNodeHttpHandlerPlugin {
|
|
14
|
-
name = "~composite/node-http";
|
|
15
|
-
plugins;
|
|
16
|
-
constructor(plugins = []) {
|
|
17
|
-
this.plugins = sortPlugins(plugins);
|
|
18
|
-
}
|
|
19
|
-
initNodeHttpHandlerOptions(options) {
|
|
20
|
-
for (const plugin of this.plugins) {
|
|
21
|
-
if (plugin.initNodeHttpHandlerOptions) {
|
|
22
|
-
options = plugin.initNodeHttpHandlerOptions(options);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return options;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
13
|
class NodeHttpHandler {
|
|
30
14
|
constructor(standardHandler, options = {}) {
|
|
31
15
|
this.standardHandler = standardHandler;
|
|
32
|
-
options = new CompositeNodeHttpHandlerPlugin(options.plugins).initNodeHttpHandlerOptions(options);
|
|
33
|
-
this.nodeHttpInterceptors = options.nodeHttpInterceptors;
|
|
34
16
|
this.sendStandardResponseOptions = options.sendStandardResponse;
|
|
35
17
|
}
|
|
36
18
|
sendStandardResponseOptions;
|
|
37
|
-
nodeHttpInterceptors;
|
|
38
19
|
async handle(request, response, ...rest) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
request,
|
|
44
|
-
response,
|
|
45
|
-
sendStandardResponseOptions: this.sendStandardResponseOptions
|
|
46
|
-
},
|
|
47
|
-
async ({ request: request2, response: response2, sendStandardResponseOptions, ...options }) => {
|
|
48
|
-
const standardRequest = toStandardLazyRequest(request2, response2);
|
|
49
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
|
50
|
-
if (!result.matched) {
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
await sendStandardResponse(response2, result.response, sendStandardResponseOptions);
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
20
|
+
const standardRequest = toStandardLazyRequest(request, response);
|
|
21
|
+
const result = await this.standardHandler.handle(
|
|
22
|
+
standardRequest,
|
|
23
|
+
resolveFriendlyStandardHandlerHandleOptions(resolveMaybeOptionalOptions(rest))
|
|
56
24
|
);
|
|
25
|
+
if (!result.matched) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
await sendStandardResponse(response, result.response, this.sendStandardResponseOptions);
|
|
29
|
+
return result;
|
|
57
30
|
}
|
|
58
31
|
}
|
|
59
32
|
|
|
@@ -65,4 +38,4 @@ class RPCHandler extends NodeHttpHandler {
|
|
|
65
38
|
}
|
|
66
39
|
}
|
|
67
40
|
|
|
68
|
-
export {
|
|
41
|
+
export { NodeHttpHandler, RPCHandler };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, R as RPCHandlerCodec, a as RPCMatcher, b as RPC_DEFAULT_ALLOW_METHODS, S as StandardHandler, T as TracingHandlerPlugin } from '../../shared/server.
|
|
1
|
+
export { C as CompositeStandardHandlerPlugin, R as RPCHandlerCodec, a as RPCMatcher, b as RPC_DEFAULT_ALLOW_METHODS, S as StandardHandler, T as TracingHandlerPlugin } from '../../shared/server.C0lFtoHU.mjs';
|
|
2
2
|
export { r as resolveFriendlyStandardHandlerHandleOptions } from '../../shared/server.W91HSRkE.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/shared';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toStringOrBytes, resolveMaybeOptionalOptions, sequential, loadBytes } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standard-server/peer';
|
|
3
3
|
import { createStandardPeerRequestHandler } from '../standard-peer/index.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 '../../shared/server.W91HSRkE.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@standard-server/core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ORPCError, toORPCError, RPCSerializer, COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
2
|
-
import { sortPlugins, toArray, matchesHttpPathPrefix, value, intercept, getTracer, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, traceAsyncIterator, traceReadableStream, recordSpanError,
|
|
2
|
+
import { sortPlugins, toArray, matchesHttpPathPrefix, value, intercept, getTracer, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, traceAsyncIterator, traceReadableStream, recordSpanError, wrapAsyncIterator, toTracingException, wrapReadableStream, pathToHttpPath, normalizeHttpPath, parseEmptyableJSON, getOwn } from '@orpc/shared';
|
|
3
3
|
import { flattenStandardHeader, parseStandardUrl, ErrorEvent } from '@standard-server/core';
|
|
4
4
|
import { c as createProcedureClient, u as unlazy, P as Procedure } from './server.Djb_ebJT.mjs';
|
|
5
5
|
import { w as walkProcedureContractsSync, g as getRouter, c as createContractProcedure, D as DEFAULT_SUCCESS_STATUS, a as DEFAULT_ERROR_STATUS } from './server.BynNaBBA.mjs';
|
|
@@ -115,66 +115,66 @@ class TracingHandlerPlugin {
|
|
|
115
115
|
}
|
|
116
116
|
const parent = tracer.extract?.(request.headers);
|
|
117
117
|
const [pathname] = parseStandardUrl(request.url);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
onFinish() {
|
|
149
|
-
span.end();
|
|
118
|
+
return tracer.startActiveSpan(`${request.method} ${pathname}`, parent, async (span) => {
|
|
119
|
+
try {
|
|
120
|
+
const result = await next();
|
|
121
|
+
if (!result.matched) {
|
|
122
|
+
span.end();
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
const body = result.response.body;
|
|
126
|
+
if (isAsyncIteratorObject(body)) {
|
|
127
|
+
return {
|
|
128
|
+
...result,
|
|
129
|
+
response: {
|
|
130
|
+
...result.response,
|
|
131
|
+
/**
|
|
132
|
+
* @remarks
|
|
133
|
+
* **Warning**: Remember use `override` for remaining special properties
|
|
134
|
+
*/
|
|
135
|
+
body: override(body, wrapAsyncIterator(body, {
|
|
136
|
+
runWith: (fn) => tracer.withActiveSpan(span, fn),
|
|
137
|
+
onError(error) {
|
|
138
|
+
if (!(error instanceof ErrorEvent)) {
|
|
139
|
+
span.recordException("error", toTracingException(error));
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
onFinish() {
|
|
143
|
+
span.end();
|
|
144
|
+
}
|
|
145
|
+
}))
|
|
150
146
|
}
|
|
151
|
-
}
|
|
147
|
+
};
|
|
152
148
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
149
|
+
if (body instanceof ReadableStream) {
|
|
150
|
+
return {
|
|
151
|
+
...result,
|
|
152
|
+
response: {
|
|
153
|
+
...result.response,
|
|
154
|
+
/**
|
|
155
|
+
* @remarks
|
|
156
|
+
* **Warning**: Remember use `override` for remaining special properties
|
|
157
|
+
*/
|
|
158
|
+
body: override(body, wrapReadableStream(body, {
|
|
159
|
+
runWith: (fn) => tracer.withActiveSpan(span, fn),
|
|
160
|
+
onError(error) {
|
|
161
|
+
span.recordException("error", toTracingException(error));
|
|
162
|
+
},
|
|
163
|
+
onFinish() {
|
|
164
|
+
span.end();
|
|
165
|
+
}
|
|
166
|
+
}))
|
|
171
167
|
}
|
|
172
|
-
}
|
|
168
|
+
};
|
|
173
169
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
span.end();
|
|
171
|
+
return result;
|
|
172
|
+
} catch (e) {
|
|
173
|
+
span.recordException("error", toTracingException(e));
|
|
174
|
+
span.end();
|
|
175
|
+
throw e;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
178
|
},
|
|
179
179
|
...toArray(options.routingInterceptors)
|
|
180
180
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.37",
|
|
5
5
|
"description": "Build typesafe APIs with oRPC: RPC and OpenAPI support, middleware, and adapters for Node.js, Bun, Deno, Fetch, Fastify, WebSocket, AWS Lambda, and more",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -117,15 +117,15 @@
|
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@orpc/client": "2.0.0-beta.
|
|
121
|
-
"@orpc/contract": "2.0.0-beta.
|
|
122
|
-
"@orpc/shared": "2.0.0-beta.
|
|
123
|
-
"@standard-server/aws-lambda": "~0.9.
|
|
124
|
-
"@standard-server/core": "~0.9.
|
|
125
|
-
"@standard-server/fastify": "~0.9.
|
|
126
|
-
"@standard-server/fetch": "~0.9.
|
|
127
|
-
"@standard-server/node": "~0.9.
|
|
128
|
-
"@standard-server/peer": "~0.9.
|
|
120
|
+
"@orpc/client": "2.0.0-beta.37",
|
|
121
|
+
"@orpc/contract": "2.0.0-beta.37",
|
|
122
|
+
"@orpc/shared": "2.0.0-beta.37",
|
|
123
|
+
"@standard-server/aws-lambda": "~0.9.2",
|
|
124
|
+
"@standard-server/core": "~0.9.2",
|
|
125
|
+
"@standard-server/fastify": "~0.9.2",
|
|
126
|
+
"@standard-server/fetch": "~0.9.2",
|
|
127
|
+
"@standard-server/node": "~0.9.2",
|
|
128
|
+
"@standard-server/peer": "~0.9.2",
|
|
129
129
|
"cookie": "^2.0.1"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|