@orpc/server 0.0.0-next.6c13765 → 0.0.0-next.6c1c681

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.
Files changed (81) hide show
  1. package/README.md +120 -0
  2. package/dist/adapters/fetch/index.d.mts +28 -0
  3. package/dist/adapters/fetch/index.d.ts +28 -0
  4. package/dist/adapters/fetch/index.mjs +9 -0
  5. package/dist/adapters/hono/index.d.mts +21 -0
  6. package/dist/adapters/hono/index.d.ts +21 -0
  7. package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
  8. package/dist/adapters/next/index.d.mts +28 -0
  9. package/dist/adapters/next/index.d.ts +28 -0
  10. package/dist/{next.js → adapters/next/index.mjs} +11 -13
  11. package/dist/adapters/node/index.d.mts +36 -0
  12. package/dist/adapters/node/index.d.ts +36 -0
  13. package/dist/adapters/node/index.mjs +32 -0
  14. package/dist/adapters/standard/index.d.mts +26 -0
  15. package/dist/adapters/standard/index.d.ts +26 -0
  16. package/dist/adapters/standard/index.mjs +6 -0
  17. package/dist/index.d.mts +278 -0
  18. package/dist/index.d.ts +278 -0
  19. package/dist/{index.js → index.mjs} +84 -155
  20. package/dist/plugins/index.d.mts +31 -0
  21. package/dist/plugins/index.d.ts +31 -0
  22. package/dist/{chunk-WQNNSBXW.js → plugins/index.mjs} +12 -29
  23. package/dist/shared/server.B3Tm0IXY.d.ts +75 -0
  24. package/dist/shared/server.BYTulgUc.d.mts +144 -0
  25. package/dist/shared/server.BYTulgUc.d.ts +144 -0
  26. package/dist/shared/server.BeJithK4.d.mts +75 -0
  27. package/dist/{chunk-MHVECKBC.js → shared/server.BtxZnWJ9.mjs} +165 -212
  28. package/dist/shared/server.Bz_xNBjz.d.mts +8 -0
  29. package/dist/shared/server.DoP20NVH.mjs +29 -0
  30. package/dist/shared/server.EhgR_5_I.d.ts +8 -0
  31. package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
  32. package/dist/{chunk-77FU7QSO.js → shared/server.jG7ZuX3S.mjs} +22 -45
  33. package/package.json +29 -34
  34. package/dist/chunk-47YYO5JS.js +0 -32
  35. package/dist/fetch.js +0 -10
  36. package/dist/node.js +0 -31
  37. package/dist/plugins.js +0 -11
  38. package/dist/src/adapters/fetch/index.d.ts +0 -3
  39. package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
  40. package/dist/src/adapters/fetch/types.d.ts +0 -14
  41. package/dist/src/adapters/hono/index.d.ts +0 -3
  42. package/dist/src/adapters/hono/middleware.d.ts +0 -12
  43. package/dist/src/adapters/next/index.d.ts +0 -3
  44. package/dist/src/adapters/next/serve.d.ts +0 -19
  45. package/dist/src/adapters/node/index.d.ts +0 -3
  46. package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
  47. package/dist/src/adapters/node/types.d.ts +0 -22
  48. package/dist/src/adapters/standard/handler.d.ts +0 -53
  49. package/dist/src/adapters/standard/index.d.ts +0 -6
  50. package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
  51. package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
  52. package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
  53. package/dist/src/adapters/standard/types.d.ts +0 -21
  54. package/dist/src/builder-variants.d.ts +0 -75
  55. package/dist/src/builder.d.ts +0 -58
  56. package/dist/src/config.d.ts +0 -6
  57. package/dist/src/context.d.ts +0 -8
  58. package/dist/src/error.d.ts +0 -12
  59. package/dist/src/hidden.d.ts +0 -8
  60. package/dist/src/implementer-procedure.d.ts +0 -33
  61. package/dist/src/implementer-variants.d.ts +0 -18
  62. package/dist/src/implementer.d.ts +0 -29
  63. package/dist/src/index.d.ts +0 -25
  64. package/dist/src/lazy-utils.d.ts +0 -6
  65. package/dist/src/lazy.d.ts +0 -22
  66. package/dist/src/middleware-decorated.d.ts +0 -11
  67. package/dist/src/middleware-utils.d.ts +0 -5
  68. package/dist/src/middleware.d.ts +0 -38
  69. package/dist/src/plugins/base.d.ts +0 -11
  70. package/dist/src/plugins/cors.d.ts +0 -19
  71. package/dist/src/plugins/index.d.ts +0 -4
  72. package/dist/src/plugins/response-headers.d.ts +0 -10
  73. package/dist/src/procedure-client.d.ts +0 -33
  74. package/dist/src/procedure-decorated.d.ts +0 -24
  75. package/dist/src/procedure-utils.d.ts +0 -19
  76. package/dist/src/procedure.d.ts +0 -31
  77. package/dist/src/router-accessible-lazy.d.ts +0 -8
  78. package/dist/src/router-client.d.ts +0 -12
  79. package/dist/src/router.d.ts +0 -30
  80. package/dist/src/utils.d.ts +0 -24
  81. package/dist/standard.js +0 -13
@@ -1,21 +1,10 @@
1
- import {
2
- convertPathToHttpPath,
3
- createContractedProcedure,
4
- createProcedureClient,
5
- eachContractProcedure,
6
- getRouterChild,
7
- isProcedure,
8
- unlazy
9
- } from "./chunk-MHVECKBC.js";
10
- import {
11
- CompositePlugin
12
- } from "./chunk-WQNNSBXW.js";
1
+ import { ORPCError, toORPCError } from '@orpc/client';
2
+ import { intercept, trim, parseEmptyableJSON } from '@orpc/shared';
3
+ import { C as CompositePlugin } from './server.Q6ZmnTgO.mjs';
4
+ import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.BtxZnWJ9.mjs';
13
5
 
14
- // src/adapters/standard/handler.ts
15
- import { ORPCError, toORPCError } from "@orpc/client";
16
- import { intercept, trim } from "@orpc/shared";
17
- var StandardHandler = class {
18
- constructor(router, matcher, codec, options = {}) {
6
+ class StandardHandler {
7
+ constructor(router, matcher, codec, options) {
19
8
  this.matcher = matcher;
20
9
  this.codec = codec;
21
10
  this.options = options;
@@ -78,17 +67,14 @@ var StandardHandler = class {
78
67
  }
79
68
  );
80
69
  }
81
- };
70
+ }
82
71
 
83
- // src/adapters/standard/rpc-codec.ts
84
- import { RPCSerializer } from "@orpc/client/rpc";
85
- var RPCCodec = class {
86
- serializer;
87
- constructor(options = {}) {
88
- this.serializer = options.serializer ?? new RPCSerializer();
72
+ class StandardRPCCodec {
73
+ constructor(serializer) {
74
+ this.serializer = serializer;
89
75
  }
90
76
  async decode(request, _params, _procedure) {
91
- const serialized = request.method === "GET" ? JSON.parse(request.url.searchParams.getAll("data").at(-1)) : await request.body();
77
+ const serialized = request.method === "GET" ? parseEmptyableJSON(request.url.searchParams.getAll("data").at(-1)) : await request.body();
92
78
  return this.serializer.deserialize(serialized);
93
79
  }
94
80
  encode(output, _procedure) {
@@ -105,18 +91,14 @@ var RPCCodec = class {
105
91
  body: this.serializer.serialize(error.toJSON())
106
92
  };
107
93
  }
108
- };
94
+ }
109
95
 
110
- // src/adapters/standard/rpc-matcher.ts
111
- var RPCMatcher = class {
96
+ class StandardRPCMatcher {
112
97
  tree = {};
113
98
  pendingRouters = [];
114
99
  init(router, path = []) {
115
- const laziedOptions = eachContractProcedure({
116
- router,
117
- path
118
- }, ({ path: path2, contract }) => {
119
- const httpPath = convertPathToHttpPath(path2);
100
+ const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
101
+ const httpPath = toHttpPath(path2);
120
102
  if (isProcedure(contract)) {
121
103
  this.tree[httpPath] = {
122
104
  path: path2,
@@ -136,7 +118,7 @@ var RPCMatcher = class {
136
118
  });
137
119
  this.pendingRouters.push(...laziedOptions.map((option) => ({
138
120
  ...option,
139
- httpPathPrefix: convertPathToHttpPath(option.path)
121
+ httpPathPrefix: toHttpPath(option.path)
140
122
  })));
141
123
  }
142
124
  async match(_method, pathname) {
@@ -144,7 +126,7 @@ var RPCMatcher = class {
144
126
  const newPendingRouters = [];
145
127
  for (const pendingRouter of this.pendingRouters) {
146
128
  if (pathname.startsWith(pendingRouter.httpPathPrefix)) {
147
- const { default: router } = await unlazy(pendingRouter.lazied);
129
+ const { default: router } = await unlazy(pendingRouter.router);
148
130
  this.init(router, pendingRouter.path);
149
131
  } else {
150
132
  newPendingRouters.push(pendingRouter);
@@ -157,25 +139,20 @@ var RPCMatcher = class {
157
139
  return void 0;
158
140
  }
159
141
  if (!match.procedure) {
160
- const { default: maybeProcedure } = await unlazy(getRouterChild(match.router, ...match.path));
142
+ const { default: maybeProcedure } = await unlazy(getRouter(match.router, match.path));
161
143
  if (!isProcedure(maybeProcedure)) {
162
144
  throw new Error(`
163
- [Contract-First] Missing or invalid implementation for procedure at path: ${convertPathToHttpPath(match.path)}.
145
+ [Contract-First] Missing or invalid implementation for procedure at path: ${toHttpPath(match.path)}.
164
146
  Ensure that the procedure is correctly defined and matches the expected contract.
165
147
  `);
166
148
  }
167
- match.procedure = createContractedProcedure(match.contract, maybeProcedure);
149
+ match.procedure = createContractedProcedure(maybeProcedure, match.contract);
168
150
  }
169
151
  return {
170
152
  path: match.path,
171
153
  procedure: match.procedure
172
154
  };
173
155
  }
174
- };
156
+ }
175
157
 
176
- export {
177
- StandardHandler,
178
- RPCCodec,
179
- RPCMatcher
180
- };
181
- //# sourceMappingURL=chunk-77FU7QSO.js.map
158
+ export { StandardHandler as S, StandardRPCCodec as a, StandardRPCMatcher as b };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.0.0-next.6c13765",
4
+ "version": "0.0.0-next.6c1c681",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,47 +15,42 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
21
21
  },
22
22
  "./plugins": {
23
- "types": "./dist/src/plugins/index.d.ts",
24
- "import": "./dist/plugins.js",
25
- "default": "./dist/plugins.js"
23
+ "types": "./dist/plugins/index.d.mts",
24
+ "import": "./dist/plugins/index.mjs",
25
+ "default": "./dist/plugins/index.mjs"
26
26
  },
27
27
  "./standard": {
28
- "types": "./dist/src/adapters/standard/index.d.ts",
29
- "import": "./dist/standard.js",
30
- "default": "./dist/standard.js"
28
+ "types": "./dist/adapters/standard/index.d.mts",
29
+ "import": "./dist/adapters/standard/index.mjs",
30
+ "default": "./dist/adapters/standard/index.mjs"
31
31
  },
32
32
  "./fetch": {
33
- "types": "./dist/src/adapters/fetch/index.d.ts",
34
- "import": "./dist/fetch.js",
35
- "default": "./dist/fetch.js"
33
+ "types": "./dist/adapters/fetch/index.d.mts",
34
+ "import": "./dist/adapters/fetch/index.mjs",
35
+ "default": "./dist/adapters/fetch/index.mjs"
36
36
  },
37
37
  "./hono": {
38
- "types": "./dist/src/adapters/hono/index.d.ts",
39
- "import": "./dist/hono.js",
40
- "default": "./dist/hono.js"
38
+ "types": "./dist/adapters/hono/index.d.mts",
39
+ "import": "./dist/adapters/hono/index.mjs",
40
+ "default": "./dist/adapters/hono/index.mjs"
41
41
  },
42
42
  "./next": {
43
- "types": "./dist/src/adapters/next/index.d.ts",
44
- "import": "./dist/next.js",
45
- "default": "./dist/next.js"
43
+ "types": "./dist/adapters/next/index.d.mts",
44
+ "import": "./dist/adapters/next/index.mjs",
45
+ "default": "./dist/adapters/next/index.mjs"
46
46
  },
47
47
  "./node": {
48
- "types": "./dist/src/adapters/node/index.d.ts",
49
- "import": "./dist/node.js",
50
- "default": "./dist/node.js"
51
- },
52
- "./🔒/*": {
53
- "types": "./dist/src/*.d.ts"
48
+ "types": "./dist/adapters/node/index.d.mts",
49
+ "import": "./dist/adapters/node/index.mjs",
50
+ "default": "./dist/adapters/node/index.mjs"
54
51
  }
55
52
  },
56
53
  "files": [
57
- "!**/*.map",
58
- "!**/*.tsbuildinfo",
59
54
  "dist"
60
55
  ],
61
56
  "peerDependencies": {
@@ -63,18 +58,18 @@
63
58
  "next": ">=14.0.0"
64
59
  },
65
60
  "dependencies": {
66
- "@orpc/server-standard": "^0.4.0",
67
- "@orpc/server-standard-fetch": "^0.4.0",
68
- "@orpc/server-standard-node": "^0.4.0",
69
- "@orpc/client": "0.0.0-next.6c13765",
70
- "@orpc/contract": "0.0.0-next.6c13765",
71
- "@orpc/shared": "0.0.0-next.6c13765"
61
+ "@orpc/client": "0.0.0-next.6c1c681",
62
+ "@orpc/shared": "0.0.0-next.6c1c681",
63
+ "@orpc/contract": "0.0.0-next.6c1c681",
64
+ "@orpc/standard-server": "0.0.0-next.6c1c681",
65
+ "@orpc/standard-server-fetch": "0.0.0-next.6c1c681",
66
+ "@orpc/standard-server-node": "0.0.0-next.6c1c681"
72
67
  },
73
68
  "devDependencies": {
74
69
  "light-my-request": "^6.5.1"
75
70
  },
76
71
  "scripts": {
77
- "build": "tsup --onSuccess='tsc -b --noCheck'",
72
+ "build": "unbuild",
78
73
  "build:watch": "pnpm run build --watch",
79
74
  "type:check": "tsc -b"
80
75
  }
@@ -1,32 +0,0 @@
1
- import {
2
- RPCCodec,
3
- RPCMatcher,
4
- StandardHandler
5
- } from "./chunk-77FU7QSO.js";
6
-
7
- // src/adapters/fetch/rpc-handler.ts
8
- import { toFetchResponse, toStandardRequest } from "@orpc/server-standard-fetch";
9
- var RPCHandler = class {
10
- standardHandler;
11
- constructor(router, options) {
12
- const matcher = options?.matcher ?? new RPCMatcher();
13
- const codec = options?.codec ?? new RPCCodec();
14
- this.standardHandler = new StandardHandler(router, matcher, codec, options);
15
- }
16
- async handle(request, ...rest) {
17
- const standardRequest = toStandardRequest(request);
18
- const result = await this.standardHandler.handle(standardRequest, ...rest);
19
- if (!result.matched) {
20
- return result;
21
- }
22
- return {
23
- matched: true,
24
- response: toFetchResponse(result.response)
25
- };
26
- }
27
- };
28
-
29
- export {
30
- RPCHandler
31
- };
32
- //# sourceMappingURL=chunk-47YYO5JS.js.map
package/dist/fetch.js DELETED
@@ -1,10 +0,0 @@
1
- import {
2
- RPCHandler
3
- } from "./chunk-47YYO5JS.js";
4
- import "./chunk-77FU7QSO.js";
5
- import "./chunk-MHVECKBC.js";
6
- import "./chunk-WQNNSBXW.js";
7
- export {
8
- RPCHandler
9
- };
10
- //# sourceMappingURL=fetch.js.map
package/dist/node.js DELETED
@@ -1,31 +0,0 @@
1
- import {
2
- RPCCodec,
3
- RPCMatcher,
4
- StandardHandler
5
- } from "./chunk-77FU7QSO.js";
6
- import "./chunk-MHVECKBC.js";
7
- import "./chunk-WQNNSBXW.js";
8
-
9
- // src/adapters/node/rpc-handler.ts
10
- import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
11
- var RPCHandler = class {
12
- standardHandler;
13
- constructor(router, options) {
14
- const codec = options?.codec ?? new RPCCodec();
15
- const matcher = options?.matcher ?? new RPCMatcher();
16
- this.standardHandler = new StandardHandler(router, matcher, codec, options);
17
- }
18
- async handle(req, res, ...rest) {
19
- const standardRequest = toStandardRequest(req, res);
20
- const result = await this.standardHandler.handle(standardRequest, ...rest);
21
- if (!result.matched) {
22
- return { matched: false };
23
- }
24
- await sendStandardResponse(res, result.response);
25
- return { matched: true };
26
- }
27
- };
28
- export {
29
- RPCHandler
30
- };
31
- //# sourceMappingURL=node.js.map
package/dist/plugins.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- CORSPlugin,
3
- CompositePlugin,
4
- ResponseHeadersPlugin
5
- } from "./chunk-WQNNSBXW.js";
6
- export {
7
- CORSPlugin,
8
- CompositePlugin,
9
- ResponseHeadersPlugin
10
- };
11
- //# sourceMappingURL=plugins.js.map
@@ -1,3 +0,0 @@
1
- export * from './rpc-handler';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { Context } from '../../context';
3
- import type { Router } from '../../router';
4
- import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
5
- import type { FetchHandler, FetchHandleResult } from './types';
6
- export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
7
- private readonly standardHandler;
8
- constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
9
- handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
10
- }
11
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,14 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { Context } from '../../context';
3
- import type { StandardHandleOptions } from '../standard';
4
- export type FetchHandleResult = {
5
- matched: true;
6
- response: Response;
7
- } | {
8
- matched: false;
9
- response: undefined;
10
- };
11
- export interface FetchHandler<T extends Context> {
12
- handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
13
- }
14
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from '../fetch';
2
- export * from './middleware';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { MaybeOptionalOptions, Value } from '@orpc/shared';
2
- import type { Context as HonoContext, MiddlewareHandler } from 'hono';
3
- import type { Context } from '../../context';
4
- import type { FetchHandler } from '../fetch';
5
- import type { StandardHandleOptions } from '../standard';
6
- export type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
7
- context?: Value<T, [HonoContext]>;
8
- } : {
9
- context: Value<T, [HonoContext]>;
10
- });
11
- export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
12
- //# sourceMappingURL=middleware.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from '../fetch';
2
- export * from './serve';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,19 +0,0 @@
1
- import type { MaybeOptionalOptions, Value } from '@orpc/shared';
2
- import type { NextRequest } from 'next/server';
3
- import type { Context } from '../../context';
4
- import type { FetchHandler } from '../fetch';
5
- import type { StandardHandleOptions } from '../standard';
6
- export type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
7
- context?: Value<T, [NextRequest]>;
8
- } : {
9
- context: Value<T, [NextRequest]>;
10
- });
11
- export interface ServeResult {
12
- GET(req: NextRequest): Promise<Response>;
13
- POST(req: NextRequest): Promise<Response>;
14
- PUT(req: NextRequest): Promise<Response>;
15
- PATCH(req: NextRequest): Promise<Response>;
16
- DELETE(req: NextRequest): Promise<Response>;
17
- }
18
- export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
19
- //# sourceMappingURL=serve.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from './rpc-handler';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { Context } from '../../context';
3
- import type { Router } from '../../router';
4
- import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
5
- import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
6
- export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
7
- private readonly standardHandler;
8
- constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
9
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
10
- }
11
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,22 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { IncomingMessage, ServerResponse } from 'node:http';
3
- import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
4
- import type { Context } from '../../context';
5
- import type { StandardHandleOptions } from '../standard';
6
- export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
7
- /**
8
- * Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
9
- * This is useful for `express.js` middleware.
10
- */
11
- originalUrl?: string;
12
- };
13
- export type NodeHttpResponse = ServerResponse | Http2ServerResponse;
14
- export type NodeHttpHandleResult = {
15
- matched: true;
16
- } | {
17
- matched: false;
18
- };
19
- export interface NodeHttpHandler<T extends Context> {
20
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
21
- }
22
- //# sourceMappingURL=types.d.ts.map
@@ -1,53 +0,0 @@
1
- import type { ErrorFromErrorMap, HTTPPath, Meta, Schema, SchemaOutput } from '@orpc/contract';
2
- import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
3
- import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
- import type { Context } from '../../context';
5
- import type { Plugin } from '../../plugins';
6
- import type { ProcedureClientInterceptorOptions } from '../../procedure-client';
7
- import type { Router } from '../../router';
8
- import type { StandardCodec, StandardMatcher } from './types';
9
- export type StandardHandleOptions<T extends Context> = {
10
- prefix?: HTTPPath;
11
- } & (Record<never, never> extends T ? {
12
- context?: T;
13
- } : {
14
- context: T;
15
- });
16
- export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
17
- context: T;
18
- };
19
- export type StandardHandleResult = {
20
- matched: true;
21
- response: StandardResponse;
22
- } | {
23
- matched: false;
24
- response: undefined;
25
- };
26
- export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
27
- request: StandardRequest;
28
- };
29
- export interface StandardHandlerOptions<TContext extends Context> {
30
- plugins?: Plugin<TContext>[];
31
- /**
32
- * Interceptors at the request level, helpful when you want catch errors
33
- */
34
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
35
- /**
36
- * Interceptors at the root level, helpful when you want override the request/response
37
- */
38
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
39
- /**
40
- *
41
- * Interceptors for procedure client.
42
- */
43
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Schema, Record<never, never>, Meta>, SchemaOutput<Schema, unknown>, ErrorFromErrorMap<Record<never, never>>>[];
44
- }
45
- export declare class StandardHandler<T extends Context> {
46
- private readonly matcher;
47
- private readonly codec;
48
- private readonly options;
49
- private readonly plugin;
50
- constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
51
- handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
52
- }
53
- //# sourceMappingURL=handler.d.ts.map
@@ -1,6 +0,0 @@
1
- export * from './handler';
2
- export * from './rpc-codec';
3
- export * from './rpc-handler';
4
- export * from './rpc-matcher';
5
- export * from './types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1,16 +0,0 @@
1
- import type { ORPCError } from '@orpc/client';
2
- import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
3
- import type { AnyProcedure } from '../../procedure';
4
- import type { StandardCodec, StandardParams } from './types';
5
- import { RPCSerializer } from '@orpc/client/rpc';
6
- export interface StandardCodecOptions {
7
- serializer?: RPCSerializer;
8
- }
9
- export declare class RPCCodec implements StandardCodec {
10
- private readonly serializer;
11
- constructor(options?: StandardCodecOptions);
12
- decode(request: StandardRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
13
- encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
14
- encodeError(error: ORPCError<any, any>): StandardResponse;
15
- }
16
- //# sourceMappingURL=rpc-codec.d.ts.map
@@ -1,8 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { StandardHandlerOptions } from './handler';
3
- import type { StandardCodec, StandardMatcher } from './types';
4
- export interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T> {
5
- matcher?: StandardMatcher;
6
- codec?: StandardCodec;
7
- }
8
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { HTTPPath } from '@orpc/contract';
2
- import type { StandardMatcher, StandardMatchResult } from './types';
3
- import { type AnyRouter } from '../../router';
4
- export declare class RPCMatcher implements StandardMatcher {
5
- private readonly tree;
6
- private pendingRouters;
7
- init(router: AnyRouter, path?: string[]): void;
8
- match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
9
- }
10
- //# sourceMappingURL=rpc-matcher.d.ts.map
@@ -1,21 +0,0 @@
1
- import type { ORPCError } from '@orpc/client';
2
- import type { HTTPPath } from '@orpc/contract';
3
- import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
4
- import type { AnyProcedure } from '../../procedure';
5
- import type { AnyRouter } from '../../router';
6
- export type StandardParams = Record<string, string>;
7
- export type StandardMatchResult = {
8
- path: string[];
9
- procedure: AnyProcedure;
10
- params?: StandardParams;
11
- } | undefined;
12
- export interface StandardMatcher {
13
- init(router: AnyRouter): void;
14
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
15
- }
16
- export interface StandardCodec {
17
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
18
- encodeError(error: ORPCError<any, any>): StandardResponse;
19
- decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
20
- }
21
- //# sourceMappingURL=types.d.ts.map