MCPcopy Create free account
hub / github.com/middleapi/orpc / createORPCClient

Function createORPCClient

packages/client/src/client.ts:17–43  ·  view source on GitHub ↗
(
  link: ClientLink<InferClientContext<T>>,
  options: createORPCClientOptions = {},
)

Source from the content-addressed store, hash-verified

15 * @see {@link https://orpc.dev/docs/client/client-side Client-side Client Docs}
16 */
17export function createORPCClient<T extends NestedClient<any>>(
18 link: ClientLink<InferClientContext<T>>,
19 options: createORPCClientOptions = {},
20): T {
21 const path = options.path ?? []
22
23 const procedureClient: Client<InferClientContext<T>, unknown, unknown, Error> = async (
24 ...[input, options = {} as FriendlyClientOptions<InferClientContext<T>>]
25 ) => {
26 return await link.call(path, input, resolveFriendlyClientOptions(options))
27 }
28
29 const recursive = new Proxy(procedureClient, {
30 get(target, key) {
31 if (typeof key !== 'string') {
32 return Reflect.get(target, key)
33 }
34
35 return createORPCClient(link, {
36 ...options,
37 path: [...path, key],
38 })
39 },
40 })
41
42 return preventNativeAwait(recursive) as any
43}

Callers 15

client.test-d.tsFile · 0.90
client.test.tsFile · 0.90
rpc-link.test.tsFile · 0.90
rpc-link.test.tsFile · 0.90
retry.test.tsFile · 0.90
batch.test.tsFile · 0.90
shared.tsFile · 0.90
helpers.tsFile · 0.90
initMethod · 0.90
getFunction · 0.90

Calls 1

preventNativeAwaitFunction · 0.90

Tested by

no test coverage detected