@orpc/server 0.0.0-next.4f63ec1 → 0.0.0-next.4fc998d
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 +122 -0
- package/dist/adapters/fetch/index.d.mts +28 -0
- package/dist/adapters/fetch/index.d.ts +28 -0
- package/dist/adapters/fetch/index.mjs +9 -0
- package/dist/adapters/hono/index.d.mts +21 -0
- package/dist/adapters/hono/index.d.ts +21 -0
- package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
- package/dist/adapters/next/index.d.mts +28 -0
- package/dist/adapters/next/index.d.ts +28 -0
- package/dist/{next.js → adapters/next/index.mjs} +11 -13
- package/dist/adapters/node/index.d.mts +36 -0
- package/dist/adapters/node/index.d.ts +36 -0
- package/dist/adapters/node/index.mjs +32 -0
- package/dist/adapters/standard/index.d.mts +26 -0
- package/dist/adapters/standard/index.d.ts +26 -0
- package/dist/adapters/standard/index.mjs +6 -0
- package/dist/index.d.mts +278 -0
- package/dist/index.d.ts +278 -0
- package/dist/{index.js → index.mjs} +84 -155
- package/dist/plugins/index.d.mts +31 -0
- package/dist/plugins/index.d.ts +31 -0
- package/dist/{chunk-XI6WGCB3.js → plugins/index.mjs} +17 -39
- package/dist/shared/server.B3Tm0IXY.d.ts +75 -0
- package/dist/shared/server.BYTulgUc.d.mts +144 -0
- package/dist/shared/server.BYTulgUc.d.ts +144 -0
- package/dist/shared/server.BeJithK4.d.mts +75 -0
- package/dist/{chunk-MHVECKBC.js → shared/server.BtxZnWJ9.mjs} +165 -212
- package/dist/shared/server.Bz_xNBjz.d.mts +8 -0
- package/dist/shared/server.DoP20NVH.mjs +29 -0
- package/dist/shared/server.EhgR_5_I.d.ts +8 -0
- package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
- package/dist/{chunk-LXOL226G.js → shared/server.jG7ZuX3S.mjs} +28 -52
- package/package.json +29 -34
- package/dist/chunk-KPT6FDBK.js +0 -32
- package/dist/fetch.js +0 -10
- package/dist/node.js +0 -31
- package/dist/plugins.js +0 -11
- package/dist/src/adapters/fetch/index.d.ts +0 -3
- package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/fetch/types.d.ts +0 -14
- package/dist/src/adapters/hono/index.d.ts +0 -3
- package/dist/src/adapters/hono/middleware.d.ts +0 -12
- package/dist/src/adapters/next/index.d.ts +0 -3
- package/dist/src/adapters/next/serve.d.ts +0 -19
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/node/types.d.ts +0 -22
- package/dist/src/adapters/standard/handler.d.ts +0 -51
- package/dist/src/adapters/standard/index.d.ts +0 -6
- package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
- package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
- package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
- package/dist/src/adapters/standard/types.d.ts +0 -21
- package/dist/src/builder-variants.d.ts +0 -75
- package/dist/src/builder.d.ts +0 -58
- package/dist/src/config.d.ts +0 -6
- package/dist/src/context.d.ts +0 -8
- package/dist/src/error.d.ts +0 -12
- package/dist/src/hidden.d.ts +0 -8
- package/dist/src/implementer-procedure.d.ts +0 -33
- package/dist/src/implementer-variants.d.ts +0 -18
- package/dist/src/implementer.d.ts +0 -29
- package/dist/src/index.d.ts +0 -25
- package/dist/src/lazy-utils.d.ts +0 -6
- package/dist/src/lazy.d.ts +0 -22
- package/dist/src/middleware-decorated.d.ts +0 -11
- package/dist/src/middleware-utils.d.ts +0 -5
- package/dist/src/middleware.d.ts +0 -38
- package/dist/src/plugins/base.d.ts +0 -13
- package/dist/src/plugins/cors.d.ts +0 -19
- package/dist/src/plugins/index.d.ts +0 -4
- package/dist/src/plugins/response-headers.d.ts +0 -10
- package/dist/src/procedure-client.d.ts +0 -33
- package/dist/src/procedure-decorated.d.ts +0 -24
- package/dist/src/procedure-utils.d.ts +0 -19
- package/dist/src/procedure.d.ts +0 -31
- package/dist/src/router-accessible-lazy.d.ts +0 -8
- package/dist/src/router-client.d.ts +0 -12
- package/dist/src/router.d.ts +0 -30
- package/dist/src/utils.d.ts +0 -24
- package/dist/standard.js +0 -13
@@ -1,32 +1,21 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
eachContractProcedure,
|
6
|
-
getRouterChild,
|
7
|
-
isProcedure,
|
8
|
-
unlazy
|
9
|
-
} from "./chunk-MHVECKBC.js";
|
10
|
-
import {
|
11
|
-
CompositePlugin
|
12
|
-
} from "./chunk-XI6WGCB3.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
|
-
|
15
|
-
|
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;
|
22
|
-
this.plugin = new CompositePlugin(options
|
11
|
+
this.plugin = new CompositePlugin(options.plugins);
|
23
12
|
this.plugin.init(this.options);
|
24
13
|
this.matcher.init(router);
|
25
14
|
}
|
26
15
|
plugin;
|
27
16
|
handle(request, ...[options]) {
|
28
17
|
return intercept(
|
29
|
-
this.options.
|
18
|
+
this.options.rootInterceptors ?? [],
|
30
19
|
{
|
31
20
|
request,
|
32
21
|
...options,
|
@@ -47,12 +36,11 @@ var StandardHandler = class {
|
|
47
36
|
if (!match) {
|
48
37
|
return { matched: false, response: void 0 };
|
49
38
|
}
|
50
|
-
const
|
39
|
+
const client = createProcedureClient(match.procedure, {
|
51
40
|
context: interceptorOptions2.context,
|
52
|
-
path: match.path
|
53
|
-
|
54
|
-
|
55
|
-
const client = createProcedureClient(match.procedure, clientOptions);
|
41
|
+
path: match.path,
|
42
|
+
interceptors: this.options.clientInterceptors
|
43
|
+
});
|
56
44
|
isDecoding = true;
|
57
45
|
const input = await this.codec.decode(request, match.params, match.procedure);
|
58
46
|
isDecoding = false;
|
@@ -79,17 +67,14 @@ var StandardHandler = class {
|
|
79
67
|
}
|
80
68
|
);
|
81
69
|
}
|
82
|
-
}
|
70
|
+
}
|
83
71
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
serializer;
|
88
|
-
constructor(options = {}) {
|
89
|
-
this.serializer = options.serializer ?? new RPCSerializer();
|
72
|
+
class StandardRPCCodec {
|
73
|
+
constructor(serializer) {
|
74
|
+
this.serializer = serializer;
|
90
75
|
}
|
91
76
|
async decode(request, _params, _procedure) {
|
92
|
-
const serialized = request.method === "GET" ?
|
77
|
+
const serialized = request.method === "GET" ? parseEmptyableJSON(request.url.searchParams.getAll("data").at(-1)) : await request.body();
|
93
78
|
return this.serializer.deserialize(serialized);
|
94
79
|
}
|
95
80
|
encode(output, _procedure) {
|
@@ -106,18 +91,14 @@ var RPCCodec = class {
|
|
106
91
|
body: this.serializer.serialize(error.toJSON())
|
107
92
|
};
|
108
93
|
}
|
109
|
-
}
|
94
|
+
}
|
110
95
|
|
111
|
-
|
112
|
-
var RPCMatcher = class {
|
96
|
+
class StandardRPCMatcher {
|
113
97
|
tree = {};
|
114
98
|
pendingRouters = [];
|
115
99
|
init(router, path = []) {
|
116
|
-
const laziedOptions =
|
117
|
-
|
118
|
-
path
|
119
|
-
}, ({ path: path2, contract }) => {
|
120
|
-
const httpPath = convertPathToHttpPath(path2);
|
100
|
+
const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
|
101
|
+
const httpPath = toHttpPath(path2);
|
121
102
|
if (isProcedure(contract)) {
|
122
103
|
this.tree[httpPath] = {
|
123
104
|
path: path2,
|
@@ -137,7 +118,7 @@ var RPCMatcher = class {
|
|
137
118
|
});
|
138
119
|
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
139
120
|
...option,
|
140
|
-
httpPathPrefix:
|
121
|
+
httpPathPrefix: toHttpPath(option.path)
|
141
122
|
})));
|
142
123
|
}
|
143
124
|
async match(_method, pathname) {
|
@@ -145,7 +126,7 @@ var RPCMatcher = class {
|
|
145
126
|
const newPendingRouters = [];
|
146
127
|
for (const pendingRouter of this.pendingRouters) {
|
147
128
|
if (pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
148
|
-
const { default: router } = await unlazy(pendingRouter.
|
129
|
+
const { default: router } = await unlazy(pendingRouter.router);
|
149
130
|
this.init(router, pendingRouter.path);
|
150
131
|
} else {
|
151
132
|
newPendingRouters.push(pendingRouter);
|
@@ -158,25 +139,20 @@ var RPCMatcher = class {
|
|
158
139
|
return void 0;
|
159
140
|
}
|
160
141
|
if (!match.procedure) {
|
161
|
-
const { default: maybeProcedure } = await unlazy(
|
142
|
+
const { default: maybeProcedure } = await unlazy(getRouter(match.router, match.path));
|
162
143
|
if (!isProcedure(maybeProcedure)) {
|
163
144
|
throw new Error(`
|
164
|
-
[Contract-First] Missing or invalid implementation for procedure at path: ${
|
145
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${toHttpPath(match.path)}.
|
165
146
|
Ensure that the procedure is correctly defined and matches the expected contract.
|
166
147
|
`);
|
167
148
|
}
|
168
|
-
match.procedure = createContractedProcedure(match.contract
|
149
|
+
match.procedure = createContractedProcedure(maybeProcedure, match.contract);
|
169
150
|
}
|
170
151
|
return {
|
171
152
|
path: match.path,
|
172
153
|
procedure: match.procedure
|
173
154
|
};
|
174
155
|
}
|
175
|
-
}
|
156
|
+
}
|
176
157
|
|
177
|
-
export {
|
178
|
-
StandardHandler,
|
179
|
-
RPCCodec,
|
180
|
-
RPCMatcher
|
181
|
-
};
|
182
|
-
//# sourceMappingURL=chunk-LXOL226G.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.
|
4
|
+
"version": "0.0.0-next.4fc998d",
|
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/
|
19
|
-
"import": "./dist/index.
|
20
|
-
"default": "./dist/index.
|
18
|
+
"types": "./dist/index.d.mts",
|
19
|
+
"import": "./dist/index.mjs",
|
20
|
+
"default": "./dist/index.mjs"
|
21
21
|
},
|
22
22
|
"./plugins": {
|
23
|
-
"types": "./dist/
|
24
|
-
"import": "./dist/plugins.
|
25
|
-
"default": "./dist/plugins.
|
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/
|
29
|
-
"import": "./dist/standard.
|
30
|
-
"default": "./dist/standard.
|
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/
|
34
|
-
"import": "./dist/fetch.
|
35
|
-
"default": "./dist/fetch.
|
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/
|
39
|
-
"import": "./dist/hono.
|
40
|
-
"default": "./dist/hono.
|
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/
|
44
|
-
"import": "./dist/next.
|
45
|
-
"default": "./dist/next.
|
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/
|
49
|
-
"import": "./dist/node.
|
50
|
-
"default": "./dist/node.
|
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/
|
67
|
-
"@orpc/
|
68
|
-
"@orpc/
|
69
|
-
"@orpc/
|
70
|
-
"@orpc/
|
71
|
-
"@orpc/
|
61
|
+
"@orpc/client": "0.0.0-next.4fc998d",
|
62
|
+
"@orpc/contract": "0.0.0-next.4fc998d",
|
63
|
+
"@orpc/shared": "0.0.0-next.4fc998d",
|
64
|
+
"@orpc/standard-server-fetch": "0.0.0-next.4fc998d",
|
65
|
+
"@orpc/standard-server": "0.0.0-next.4fc998d",
|
66
|
+
"@orpc/standard-server-node": "0.0.0-next.4fc998d"
|
72
67
|
},
|
73
68
|
"devDependencies": {
|
74
69
|
"light-my-request": "^6.5.1"
|
75
70
|
},
|
76
71
|
"scripts": {
|
77
|
-
"build": "
|
72
|
+
"build": "unbuild",
|
78
73
|
"build:watch": "pnpm run build --watch",
|
79
74
|
"type:check": "tsc -b"
|
80
75
|
}
|
package/dist/chunk-KPT6FDBK.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
RPCCodec,
|
3
|
-
RPCMatcher,
|
4
|
-
StandardHandler
|
5
|
-
} from "./chunk-LXOL226G.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-KPT6FDBK.js.map
|
package/dist/fetch.js
DELETED
package/dist/node.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
RPCCodec,
|
3
|
-
RPCMatcher,
|
4
|
-
StandardHandler
|
5
|
-
} from "./chunk-LXOL226G.js";
|
6
|
-
import "./chunk-MHVECKBC.js";
|
7
|
-
import "./chunk-XI6WGCB3.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 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,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,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,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,51 +0,0 @@
|
|
1
|
-
import type { ErrorMap, HTTPPath, Meta, Schema } 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 { CreateProcedureClientOptions } 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 type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, Record<never, never>> & {
|
30
|
-
context: TContext;
|
31
|
-
};
|
32
|
-
export interface StandardHandlerOptions<TContext extends Context> {
|
33
|
-
plugins?: Plugin<TContext>[];
|
34
|
-
/**
|
35
|
-
* Interceptors at the request level, helpful when you want catch errors
|
36
|
-
*/
|
37
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
38
|
-
/**
|
39
|
-
* Interceptors at the root level, helpful when you want override the response
|
40
|
-
*/
|
41
|
-
interceptorsRoot?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
42
|
-
}
|
43
|
-
export declare class StandardHandler<T extends Context> {
|
44
|
-
private readonly matcher;
|
45
|
-
private readonly codec;
|
46
|
-
private readonly options;
|
47
|
-
private readonly plugin;
|
48
|
-
constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
|
49
|
-
handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
|
50
|
-
}
|
51
|
-
//# sourceMappingURL=handler.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
|