@orpc/server 0.0.0-next.3b7800f → 0.0.0-next.3bec7fc
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 +5 -1
- package/dist/adapters/aws-lambda/index.d.mts +5 -5
- package/dist/adapters/aws-lambda/index.d.ts +5 -5
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/bun-ws/index.d.mts +5 -5
- package/dist/adapters/bun-ws/index.d.ts +5 -5
- package/dist/adapters/bun-ws/index.mjs +2 -2
- package/dist/adapters/crossws/index.d.mts +5 -5
- package/dist/adapters/crossws/index.d.ts +5 -5
- package/dist/adapters/crossws/index.mjs +2 -2
- package/dist/adapters/fastify/index.d.mts +53 -0
- package/dist/adapters/fastify/index.d.ts +53 -0
- package/dist/adapters/fastify/index.mjs +54 -0
- package/dist/adapters/fetch/index.d.mts +7 -7
- package/dist/adapters/fetch/index.d.ts +7 -7
- package/dist/adapters/fetch/index.mjs +5 -4
- package/dist/adapters/message-port/index.d.mts +35 -9
- package/dist/adapters/message-port/index.d.ts +35 -9
- package/dist/adapters/message-port/index.mjs +28 -12
- package/dist/adapters/node/index.d.mts +8 -8
- package/dist/adapters/node/index.d.ts +8 -8
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/standard-peer/index.d.mts +3 -3
- package/dist/adapters/standard-peer/index.d.ts +3 -3
- package/dist/adapters/websocket/index.d.mts +9 -7
- package/dist/adapters/websocket/index.d.ts +9 -7
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/adapters/ws/index.d.mts +5 -5
- package/dist/adapters/ws/index.d.ts +5 -5
- package/dist/adapters/ws/index.mjs +2 -2
- package/dist/helpers/index.d.mts +16 -1
- package/dist/helpers/index.d.ts +16 -1
- package/dist/helpers/index.mjs +11 -1
- package/dist/hibernation/index.d.mts +2 -2
- package/dist/hibernation/index.d.ts +2 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +8 -5
- package/dist/plugins/index.d.mts +5 -2
- package/dist/plugins/index.d.ts +5 -2
- package/dist/plugins/index.mjs +13 -11
- package/dist/shared/{server.CYNGeoCm.d.mts → server.B4BGqy3Y.d.mts} +2 -3
- package/dist/shared/{server.CYNGeoCm.d.ts → server.B4BGqy3Y.d.ts} +2 -3
- package/dist/shared/{server.CYRYFTxo.mjs → server.Bxx6tqNe.mjs} +1 -1
- package/dist/shared/{server.D0H-iaY3.d.ts → server.COL12UTb.d.ts} +3 -3
- package/dist/shared/{server.BEFBl-Cb.d.mts → server.CVKCo60T.d.mts} +2 -2
- package/dist/shared/{server.jMTkVNIb.d.ts → server.Cb6yD7DZ.d.ts} +1 -1
- package/dist/shared/{server.BU4WI18A.d.mts → server.Ck-gOLzq.d.mts} +3 -3
- package/dist/shared/{server.gqRxT-yN.d.mts → server.DBCUJijK.d.mts} +1 -1
- package/dist/shared/{server.B7b2w3_i.d.ts → server.DNtJ-p60.d.ts} +2 -2
- package/dist/shared/{server.Bmh5xd4n.d.ts → server.DPIFWpxG.d.ts} +1 -1
- package/dist/shared/{server.B_fj3X5m.mjs → server.Ds4HPpvH.mjs} +31 -30
- package/dist/shared/{server.DhJj-1X9.d.mts → server.DzV1hr3z.d.mts} +1 -1
- package/dist/shared/{server.BW-nUGgA.mjs → server.TEVCLCFC.mjs} +3 -0
- package/package.json +21 -12
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
35
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
36
|
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
34
|
-
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
35
38
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
36
39
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
37
40
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -54,6 +57,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
54
57
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
55
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
59
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
57
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
58
62
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
59
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, APIGatewayProxyEventV2, ResponseStream } from '@orpc/standard-server-aws-lambda';
|
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
4
|
-
import { f as StandardHandler } from '../../shared/server.
|
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
4
|
+
import { f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CVKCo60T.mjs';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/contract';
|
|
9
9
|
import '@orpc/standard-server';
|
|
10
10
|
import '@orpc/client/standard';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
12
12
|
|
|
13
13
|
interface AwsLambdaHandlerOptions extends SendStandardResponseOptions {
|
|
14
14
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { SendStandardResponseOptions, APIGatewayProxyEventV2, ResponseStream } from '@orpc/standard-server-aws-lambda';
|
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
4
|
-
import { f as StandardHandler } from '../../shared/server.
|
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
4
|
+
import { f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DNtJ-p60.js';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/contract';
|
|
9
9
|
import '@orpc/standard-server';
|
|
10
10
|
import '@orpc/client/standard';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
12
12
|
|
|
13
13
|
interface AwsLambdaHandlerOptions extends SendStandardResponseOptions {
|
|
14
14
|
}
|
|
@@ -5,11 +5,11 @@ import '@orpc/standard-server';
|
|
|
5
5
|
import '@orpc/standard-server/batch';
|
|
6
6
|
import '@orpc/standard-server-fetch';
|
|
7
7
|
import '@orpc/client';
|
|
8
|
-
import { S as StrictGetMethodPlugin } from '../../shared/server.
|
|
8
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
9
9
|
import '@orpc/contract';
|
|
10
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
10
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
11
11
|
import '@orpc/client/standard';
|
|
12
|
-
import '../../shared/server.
|
|
12
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
13
13
|
|
|
14
14
|
class AwsLambdaHandler {
|
|
15
15
|
constructor(standardHandler, options = {}) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
3
|
-
import { f as StandardHandler } from '../../shared/server.
|
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
3
|
+
import { f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
4
4
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
import '@orpc/standard-server';
|
|
9
9
|
import '@orpc/standard-server-peer';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.CVKCo60T.mjs';
|
|
11
11
|
import '@orpc/client/standard';
|
|
12
|
-
import '../../shared/server.
|
|
12
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
13
13
|
|
|
14
14
|
interface ServerWebSocket {
|
|
15
15
|
send(message: string | ArrayBufferLike | Uint8Array): number;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
3
|
-
import { f as StandardHandler } from '../../shared/server.
|
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
3
|
+
import { f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
4
4
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
6
6
|
import '@orpc/client';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
import '@orpc/standard-server';
|
|
9
9
|
import '@orpc/standard-server-peer';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.DNtJ-p60.js';
|
|
11
11
|
import '@orpc/client/standard';
|
|
12
|
-
import '../../shared/server.
|
|
12
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
13
13
|
|
|
14
14
|
interface ServerWebSocket {
|
|
15
15
|
send(message: string | ArrayBufferLike | Uint8Array): number;
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
11
11
|
|
|
12
12
|
class BunWsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { Peer, Message } from 'crossws';
|
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
4
|
-
import { f as StandardHandler } from '../../shared/server.
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
4
|
+
import { f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
5
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/contract';
|
|
9
9
|
import '@orpc/standard-server';
|
|
10
10
|
import '@orpc/standard-server-peer';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.CVKCo60T.mjs';
|
|
12
12
|
import '@orpc/client/standard';
|
|
13
|
-
import '../../shared/server.
|
|
13
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
14
14
|
|
|
15
15
|
declare class experimental_CrosswsHandler<T extends Context> {
|
|
16
16
|
private readonly standardHandler;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { Peer, Message } from 'crossws';
|
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
4
|
-
import { f as StandardHandler } from '../../shared/server.
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
4
|
+
import { f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
5
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/contract';
|
|
9
9
|
import '@orpc/standard-server';
|
|
10
10
|
import '@orpc/standard-server-peer';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.DNtJ-p60.js';
|
|
12
12
|
import '@orpc/client/standard';
|
|
13
|
-
import '../../shared/server.
|
|
13
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
14
14
|
|
|
15
15
|
declare class experimental_CrosswsHandler<T extends Context> {
|
|
16
16
|
private readonly standardHandler;
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
11
11
|
|
|
12
12
|
class experimental_CrosswsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { FastifyRequest, FastifyReply, SendStandardResponseOptions } from '@orpc/standard-server-fastify';
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
4
|
+
import { b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CVKCo60T.mjs';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
7
|
+
import '@orpc/client';
|
|
8
|
+
import '@orpc/contract';
|
|
9
|
+
import '@orpc/standard-server';
|
|
10
|
+
import '@orpc/client/standard';
|
|
11
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
12
|
+
|
|
13
|
+
type FastifyHandleResult = {
|
|
14
|
+
matched: true;
|
|
15
|
+
} | {
|
|
16
|
+
matched: false;
|
|
17
|
+
};
|
|
18
|
+
interface FastifyInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
|
19
|
+
request: FastifyRequest;
|
|
20
|
+
reply: FastifyReply;
|
|
21
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
|
22
|
+
}
|
|
23
|
+
interface FastifyHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
|
24
|
+
adapterInterceptors?: Interceptor<FastifyInterceptorOptions<T>, Promise<FastifyHandleResult>>[];
|
|
25
|
+
}
|
|
26
|
+
declare class FastifyHandler<T extends Context> {
|
|
27
|
+
private readonly standardHandler;
|
|
28
|
+
private readonly sendStandardResponseOptions;
|
|
29
|
+
private readonly adapterInterceptors;
|
|
30
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
31
|
+
handle(request: FastifyRequest, reply: FastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FastifyHandleResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardRPCHandlerOptions<T> {
|
|
35
|
+
/**
|
|
36
|
+
* Enables or disables the StrictGetMethodPlugin.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
strictGetMethodPluginEnabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* RPC Handler for Fastify Server
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
|
46
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
47
|
+
*/
|
|
48
|
+
declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
49
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { FastifyHandler, RPCHandler };
|
|
53
|
+
export type { FastifyHandleResult, FastifyHandlerOptions, FastifyInterceptorOptions, RPCHandlerOptions };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { FastifyRequest, FastifyReply, SendStandardResponseOptions } from '@orpc/standard-server-fastify';
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
4
|
+
import { b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DNtJ-p60.js';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
7
|
+
import '@orpc/client';
|
|
8
|
+
import '@orpc/contract';
|
|
9
|
+
import '@orpc/standard-server';
|
|
10
|
+
import '@orpc/client/standard';
|
|
11
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
12
|
+
|
|
13
|
+
type FastifyHandleResult = {
|
|
14
|
+
matched: true;
|
|
15
|
+
} | {
|
|
16
|
+
matched: false;
|
|
17
|
+
};
|
|
18
|
+
interface FastifyInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
|
19
|
+
request: FastifyRequest;
|
|
20
|
+
reply: FastifyReply;
|
|
21
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
|
22
|
+
}
|
|
23
|
+
interface FastifyHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
|
24
|
+
adapterInterceptors?: Interceptor<FastifyInterceptorOptions<T>, Promise<FastifyHandleResult>>[];
|
|
25
|
+
}
|
|
26
|
+
declare class FastifyHandler<T extends Context> {
|
|
27
|
+
private readonly standardHandler;
|
|
28
|
+
private readonly sendStandardResponseOptions;
|
|
29
|
+
private readonly adapterInterceptors;
|
|
30
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
31
|
+
handle(request: FastifyRequest, reply: FastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FastifyHandleResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardRPCHandlerOptions<T> {
|
|
35
|
+
/**
|
|
36
|
+
* Enables or disables the StrictGetMethodPlugin.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
strictGetMethodPluginEnabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* RPC Handler for Fastify Server
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
|
46
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
47
|
+
*/
|
|
48
|
+
declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
49
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { FastifyHandler, RPCHandler };
|
|
53
|
+
export type { FastifyHandleResult, FastifyHandlerOptions, FastifyInterceptorOptions, RPCHandlerOptions };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-fastify';
|
|
3
|
+
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
4
|
+
import '@orpc/standard-server';
|
|
5
|
+
import '@orpc/standard-server/batch';
|
|
6
|
+
import '@orpc/standard-server-fetch';
|
|
7
|
+
import '@orpc/client';
|
|
8
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
9
|
+
import '@orpc/contract';
|
|
10
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
11
|
+
import '@orpc/client/standard';
|
|
12
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
13
|
+
|
|
14
|
+
class FastifyHandler {
|
|
15
|
+
constructor(standardHandler, options = {}) {
|
|
16
|
+
this.standardHandler = standardHandler;
|
|
17
|
+
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
|
18
|
+
this.sendStandardResponseOptions = options;
|
|
19
|
+
}
|
|
20
|
+
sendStandardResponseOptions;
|
|
21
|
+
adapterInterceptors;
|
|
22
|
+
async handle(request, reply, ...rest) {
|
|
23
|
+
return intercept(
|
|
24
|
+
this.adapterInterceptors,
|
|
25
|
+
{
|
|
26
|
+
...resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest)),
|
|
27
|
+
request,
|
|
28
|
+
reply,
|
|
29
|
+
sendStandardResponseOptions: this.sendStandardResponseOptions
|
|
30
|
+
},
|
|
31
|
+
async ({ request: request2, reply: reply2, sendStandardResponseOptions, ...options }) => {
|
|
32
|
+
const standardRequest = toStandardLazyRequest(request2, reply2);
|
|
33
|
+
const result = await this.standardHandler.handle(standardRequest, options);
|
|
34
|
+
if (!result.matched) {
|
|
35
|
+
return { matched: false };
|
|
36
|
+
}
|
|
37
|
+
await sendStandardResponse(reply2, result.response, sendStandardResponseOptions);
|
|
38
|
+
return { matched: true };
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class RPCHandler extends FastifyHandler {
|
|
45
|
+
constructor(router, options = {}) {
|
|
46
|
+
if (options.strictGetMethodPluginEnabled ?? true) {
|
|
47
|
+
options.plugins ??= [];
|
|
48
|
+
options.plugins.push(new StrictGetMethodPlugin());
|
|
49
|
+
}
|
|
50
|
+
super(new StandardRPCHandler(router, options), options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { FastifyHandler, RPCHandler };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
|
4
|
-
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.
|
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
4
|
+
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CVKCo60T.mjs';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/contract';
|
|
9
9
|
import '@orpc/standard-server';
|
|
10
10
|
import '@orpc/client/standard';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
12
12
|
|
|
13
13
|
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
14
14
|
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
|
@@ -102,14 +102,14 @@ declare class CompressionPlugin<T extends Context> implements FetchHandlerPlugin
|
|
|
102
102
|
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardRPCHandlerOptions<T>, 'plugins'> {
|
|
106
106
|
/**
|
|
107
107
|
* Enables or disables the StrictGetMethodPlugin.
|
|
108
108
|
*
|
|
109
109
|
* @default true
|
|
110
110
|
*/
|
|
111
111
|
strictGetMethodPluginEnabled?: boolean;
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
/**
|
|
114
114
|
* RPC Handler for Fetch Server
|
|
115
115
|
*
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
3
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
|
4
|
-
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.
|
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
4
|
+
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DNtJ-p60.js';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/contract';
|
|
9
9
|
import '@orpc/standard-server';
|
|
10
10
|
import '@orpc/client/standard';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
12
12
|
|
|
13
13
|
interface FetchHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
|
14
14
|
initRuntimeAdapter?(options: FetchHandlerOptions<T>): void;
|
|
@@ -102,14 +102,14 @@ declare class CompressionPlugin<T extends Context> implements FetchHandlerPlugin
|
|
|
102
102
|
initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
interface RPCHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, Omit<StandardRPCHandlerOptions<T>, 'plugins'> {
|
|
106
106
|
/**
|
|
107
107
|
* Enables or disables the StrictGetMethodPlugin.
|
|
108
108
|
*
|
|
109
109
|
* @default true
|
|
110
110
|
*/
|
|
111
111
|
strictGetMethodPluginEnabled?: boolean;
|
|
112
|
-
}
|
|
112
|
+
}
|
|
113
113
|
/**
|
|
114
114
|
* RPC Handler for Fetch Server
|
|
115
115
|
*
|
|
@@ -4,11 +4,11 @@ import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fe
|
|
|
4
4
|
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '@orpc/standard-server/batch';
|
|
10
|
-
import { S as StrictGetMethodPlugin } from '../../shared/server.
|
|
11
|
-
import '../../shared/server.
|
|
10
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
11
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
12
12
|
|
|
13
13
|
class BodyLimitPlugin {
|
|
14
14
|
maxBodySize;
|
|
@@ -103,7 +103,8 @@ class CompressionPlugin {
|
|
|
103
103
|
return {
|
|
104
104
|
...result,
|
|
105
105
|
response: new Response(compressedBody, {
|
|
106
|
-
|
|
106
|
+
status: response.status,
|
|
107
|
+
statusText: response.statusText,
|
|
107
108
|
headers: compressedHeaders
|
|
108
109
|
})
|
|
109
110
|
};
|
|
@@ -1,23 +1,48 @@
|
|
|
1
1
|
import { SupportedMessagePort } from '@orpc/client/message-port';
|
|
2
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
+
import { DecodedResponseMessage } from '@orpc/standard-server-peer';
|
|
4
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
5
|
+
import { f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
6
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
7
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
7
8
|
import '@orpc/client';
|
|
8
9
|
import '@orpc/contract';
|
|
9
10
|
import '@orpc/standard-server';
|
|
10
|
-
import '
|
|
11
|
-
import '../../shared/server.BEFBl-Cb.mjs';
|
|
11
|
+
import '../../shared/server.CVKCo60T.mjs';
|
|
12
12
|
import '@orpc/client/standard';
|
|
13
|
-
import '../../shared/server.
|
|
13
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
14
14
|
|
|
15
|
+
interface MessagePortHandlerOptions<_T extends Context> {
|
|
16
|
+
/**
|
|
17
|
+
* By default, oRPC serializes request/response messages to string/binary data before sending over message port.
|
|
18
|
+
* If needed, you can define the this option to utilize full power of [MessagePort: postMessage() method](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage),
|
|
19
|
+
* such as transferring ownership of objects to the other side or support unserializable objects like `OffscreenCanvas`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - return null | undefined to disable this feature
|
|
23
|
+
*
|
|
24
|
+
* @warning Make sure your message port supports `transfer` before using this feature.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* experimental_transfer: (message, port) => {
|
|
28
|
+
* const transfer = deepFindTransferableObjects(message) // implement your own logic
|
|
29
|
+
* return transfer.length ? transfer : null // only enable when needed
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port#transfer Message Port Transfer Docs}
|
|
34
|
+
*/
|
|
35
|
+
experimental_transfer?: Value<Promisable<object[] | null | undefined>, [message: DecodedResponseMessage, port: SupportedMessagePort]>;
|
|
36
|
+
}
|
|
15
37
|
declare class MessagePortHandler<T extends Context> {
|
|
16
38
|
private readonly standardHandler;
|
|
17
|
-
|
|
39
|
+
private readonly transfer;
|
|
40
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<MessagePortHandlerOptions<T>>);
|
|
18
41
|
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
|
19
42
|
}
|
|
20
43
|
|
|
44
|
+
interface RPCHandlerOptions<T extends Context> extends StandardRPCHandlerOptions<T>, MessagePortHandlerOptions<T> {
|
|
45
|
+
}
|
|
21
46
|
/**
|
|
22
47
|
* RPC Handler for common message port implementations.
|
|
23
48
|
*
|
|
@@ -25,7 +50,8 @@ declare class MessagePortHandler<T extends Context> {
|
|
|
25
50
|
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port Message Port Adapter Docs}
|
|
26
51
|
*/
|
|
27
52
|
declare class RPCHandler<T extends Context> extends MessagePortHandler<T> {
|
|
28
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
|
53
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
export { MessagePortHandler, RPCHandler };
|
|
57
|
+
export type { MessagePortHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,23 +1,48 @@
|
|
|
1
1
|
import { SupportedMessagePort } from '@orpc/client/message-port';
|
|
2
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
+
import { DecodedResponseMessage } from '@orpc/standard-server-peer';
|
|
4
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
5
|
+
import { f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
6
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
|
7
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
7
8
|
import '@orpc/client';
|
|
8
9
|
import '@orpc/contract';
|
|
9
10
|
import '@orpc/standard-server';
|
|
10
|
-
import '
|
|
11
|
-
import '../../shared/server.B7b2w3_i.js';
|
|
11
|
+
import '../../shared/server.DNtJ-p60.js';
|
|
12
12
|
import '@orpc/client/standard';
|
|
13
|
-
import '../../shared/server.
|
|
13
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
14
14
|
|
|
15
|
+
interface MessagePortHandlerOptions<_T extends Context> {
|
|
16
|
+
/**
|
|
17
|
+
* By default, oRPC serializes request/response messages to string/binary data before sending over message port.
|
|
18
|
+
* If needed, you can define the this option to utilize full power of [MessagePort: postMessage() method](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage),
|
|
19
|
+
* such as transferring ownership of objects to the other side or support unserializable objects like `OffscreenCanvas`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - return null | undefined to disable this feature
|
|
23
|
+
*
|
|
24
|
+
* @warning Make sure your message port supports `transfer` before using this feature.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* experimental_transfer: (message, port) => {
|
|
28
|
+
* const transfer = deepFindTransferableObjects(message) // implement your own logic
|
|
29
|
+
* return transfer.length ? transfer : null // only enable when needed
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port#transfer Message Port Transfer Docs}
|
|
34
|
+
*/
|
|
35
|
+
experimental_transfer?: Value<Promisable<object[] | null | undefined>, [message: DecodedResponseMessage, port: SupportedMessagePort]>;
|
|
36
|
+
}
|
|
15
37
|
declare class MessagePortHandler<T extends Context> {
|
|
16
38
|
private readonly standardHandler;
|
|
17
|
-
|
|
39
|
+
private readonly transfer;
|
|
40
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<MessagePortHandlerOptions<T>>);
|
|
18
41
|
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
|
19
42
|
}
|
|
20
43
|
|
|
44
|
+
interface RPCHandlerOptions<T extends Context> extends StandardRPCHandlerOptions<T>, MessagePortHandlerOptions<T> {
|
|
45
|
+
}
|
|
21
46
|
/**
|
|
22
47
|
* RPC Handler for common message port implementations.
|
|
23
48
|
*
|
|
@@ -25,7 +50,8 @@ declare class MessagePortHandler<T extends Context> {
|
|
|
25
50
|
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port Message Port Adapter Docs}
|
|
26
51
|
*/
|
|
27
52
|
declare class RPCHandler<T extends Context> extends MessagePortHandler<T> {
|
|
28
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
|
53
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
export { MessagePortHandler, RPCHandler };
|
|
57
|
+
export type { MessagePortHandlerOptions, RPCHandlerOptions };
|