@orpc/server 1.10.1 → 1.10.3

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.
@@ -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 };
@@ -32,7 +32,7 @@ interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponse
32
32
  adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, Promise<NodeHttpHandleResult>>[];
33
33
  plugins?: NodeHttpHandlerPlugin<T>[];
34
34
  }
35
- declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
35
+ declare class NodeHttpHandler<T extends Context> {
36
36
  private readonly standardHandler;
37
37
  private readonly sendStandardResponseOptions;
38
38
  private readonly adapterInterceptors;
@@ -32,7 +32,7 @@ interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponse
32
32
  adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, Promise<NodeHttpHandleResult>>[];
33
33
  plugins?: NodeHttpHandlerPlugin<T>[];
34
34
  }
35
- declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
35
+ declare class NodeHttpHandler<T extends Context> {
36
36
  private readonly standardHandler;
37
37
  private readonly sendStandardResponseOptions;
38
38
  private readonly adapterInterceptors;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "1.10.1",
4
+ "version": "1.10.3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -54,6 +54,11 @@
54
54
  "import": "./dist/adapters/node/index.mjs",
55
55
  "default": "./dist/adapters/node/index.mjs"
56
56
  },
57
+ "./fastify": {
58
+ "types": "./dist/adapters/fastify/index.d.mts",
59
+ "import": "./dist/adapters/fastify/index.mjs",
60
+ "default": "./dist/adapters/fastify/index.mjs"
61
+ },
57
62
  "./aws-lambda": {
58
63
  "types": "./dist/adapters/aws-lambda/index.d.mts",
59
64
  "import": "./dist/adapters/aws-lambda/index.mjs",
@@ -102,24 +107,26 @@
102
107
  },
103
108
  "dependencies": {
104
109
  "cookie": "^1.0.2",
105
- "@orpc/client": "1.10.1",
106
- "@orpc/interop": "1.10.1",
107
- "@orpc/shared": "1.10.1",
108
- "@orpc/contract": "1.10.1",
109
- "@orpc/standard-server-aws-lambda": "1.10.1",
110
- "@orpc/standard-server": "1.10.1",
111
- "@orpc/standard-server-node": "1.10.1",
112
- "@orpc/standard-server-fetch": "1.10.1",
113
- "@orpc/standard-server-peer": "1.10.1"
110
+ "@orpc/client": "1.10.3",
111
+ "@orpc/contract": "1.10.3",
112
+ "@orpc/interop": "1.10.3",
113
+ "@orpc/shared": "1.10.3",
114
+ "@orpc/standard-server-aws-lambda": "1.10.3",
115
+ "@orpc/standard-server-fastify": "1.10.3",
116
+ "@orpc/standard-server": "1.10.3",
117
+ "@orpc/standard-server-fetch": "1.10.3",
118
+ "@orpc/standard-server-node": "1.10.3",
119
+ "@orpc/standard-server-peer": "1.10.3"
114
120
  },
115
121
  "devDependencies": {
116
- "@tanstack/router-core": "^1.133.20",
122
+ "@tanstack/router-core": "^1.133.36",
117
123
  "@types/ws": "^8.18.1",
118
124
  "crossws": "^0.4.1",
119
- "next": "^15.5.6",
125
+ "fastify": "^5.6.1",
126
+ "next": "^16.0.1",
120
127
  "supertest": "^7.1.4",
121
128
  "ws": "^8.18.3",
122
- "zod": "^4.1.11"
129
+ "zod": "^4.1.12"
123
130
  },
124
131
  "scripts": {
125
132
  "build": "unbuild",