Skip to main content
Module

x/cav/rpc.ts>Rpc

A server framework for Deno
Go to Latest
interface Rpc
import { type Rpc } from "https://deno.land/x/cav@0.0.20/rpc.ts";

An http.Handler constructed by an RpcFactory. Rpcs are one of two fundamental building blocks of Cav server applications, the other being Stacks. Rpcs are responsible for handling a request, and Stacks are responsible for routing a request to the appropriate Rpc. Once a Request reaches an Rpc and the Rpc's path matches the request, the Rpc is expected to handle all errors and return a Response. If the path doesn't match the Rpc's path, the special NO_MATCH error will be thrown. Uncaught errors bubble up to and are handled by the top-level Server, which will log them and respond with a 500 Response.

Type Parameters

optional
I extends AnyRpcInit = Record<never, never>

Call Signatures

(req: EndpointRequest<ParserInput<I["query"]>, ParserInput<I["message"]>, I["upgrade"] extends true ? true : never>, conn: http.ConnInfo): Promise<EndpointResponse<I["resolve"] extends (...a: any[]) => Promise<infer R> | infer R ? R : unknown>>

Properties

readonly
init: I

The RpcInit options used to construct this Rpc.