Skip to content
Oxide
Esc
navigateopen⌘Jpreview
On this page

API Reference

A short list of every public export, with links to the pages that explain them.

tacho

export from
tacho() tacho Procedure builder. Call it as rpc({ ... }) to make a router.
router(def) tacho Identity helper. Same as rpc({ ... }).
RpcError tacho Throw from a procedure or middleware. See errors.
JSON_RPC_ERROR tacho -32700 parse, -32600 invalid request, -32601 method not found, -32602 invalid params, -32603 internal.
APP_ERROR_RANGE tacho { min: -32099, max: -32000 } for your own codes.
toOpenRpc(router, info) tacho Walk a router into an OpenRPC document.

Transports

export from
handle(router, opts?) tacho/transport/fetch (Request) => Promise<Response>. HTTP.
createClient(opts) tacho/client/http Typed proxy over POST.
handle(router, opts?) tacho/transport/ws crossws hooks. WebSocket.
createClient(opts) tacho/client/ws One socket. .ready and .close().

A File or Blob in params or the result is Files. An async function* is SSE.

Low-level

For a custom transport.

function resolveProcedure(router: AnyRouter, method: string): ProcedureDef<any, any, any> | undefinedresolveProcedure(
const router: {
    ping: ProcedureDef<{}, undefined, "pong">;
}
router
, "ping");
await
function runOne(router: AnyRouter, raw: unknown, ctx: Context, opts?: {
    stream?: false;
}): Promise<JsonRpcResponse | undefined> (+1 overload)
runOne
(
const router: {
    ping: ProcedureDef<{}, undefined, "pong">;
}
router
, { jsonrpc: stringjsonrpc: "2.0", method: stringmethod: "ping", id: numberid: 1 },
const ctx: {
    req: Request;
}
ctx
);
await function runBatch(router: AnyRouter, items: unknown[], ctx: Context): Promise<JsonRpcErrorResponse | JsonRpcResponse[] | undefined>runBatch(
const router: {
    ping: ProcedureDef<{}, undefined, "pong">;
}
router
,
[{ jsonrpc: stringjsonrpc: "2.0", method: stringmethod: "ping", id: numberid: 1 }],
const ctx: {
    req: Request;
}
ctx
,
);
function rpcResult(body: {
    result?: unknown;
    error?: {
        message: string;
        code?: number;
        data?: unknown;
    };
}): unknown
rpcResult
({ result?: unknownresult: "pong" });
function rpcResult(body: {
    result?: unknown;
    error?: {
        message: string;
        code?: number;
        data?: unknown;
    };
}): unknown
rpcResult
({
error?: {
    message: string;
    code?: number;
    data?: unknown;
} | undefined
error
: { message: stringmessage: "nope", code?: number | undefinedcode: -32603 } });
const
const client: RPCClient<{
    ping: ProcedureDef<{}, undefined, "pong">;
}>
client
=
createProxyClient<{
    ping: ProcedureDef<{}, undefined, "pong">;
}, {}>(send: (method: string, params: unknown, opts?: CallOptions) => Promise<unknown>, extras?: {} | undefined): RPCClient<{
    ping: ProcedureDef<{}, undefined, "pong">;
}>
createProxyClient
<typeof
const router: {
    ping: ProcedureDef<{}, undefined, "pong">;
}
router
>(
async (method: stringmethod, params: unknownparams) => { const const res: JsonRpcResponse | undefinedres = await
function runOne(router: AnyRouter, raw: unknown, ctx: Context, opts?: {
    stream?: false;
}): Promise<JsonRpcResponse | undefined> (+1 overload)
runOne
(
const router: {
    ping: ProcedureDef<{}, undefined, "pong">;
}
router
,
{ jsonrpc: stringjsonrpc: "2.0", method: stringmethod, params: unknownparams, id: numberid: 1 },
const ctx: {
    req: Request;
}
ctx
,
); return
function rpcResult(body: {
    result?: unknown;
    error?: {
        message: string;
        code?: number;
        data?: unknown;
    };
}): unknown
rpcResult
(const res: JsonRpcResponse | undefinedres ?? {});
}, ); await
const client: RPCClient<{
    ping: ProcedureDef<{}, undefined, "pong">;
}>
client
.ping: (input?: undefined, opts?: CallOptions | undefined) => Promise<"pong">ping();
export
resolveProcedure(router, method) Procedure, or undefined.
runOne(router, request, ctx) One JSON-RPC call. No idundefined (notification).
runBatch(router, requests, ctx) Many calls. All notifications → undefined.
rpcResult(body) Result, or throws RpcError.
createProxyClient(send) Typed proxy over your own send.

Was this page helpful?