Skip to main content
Module

x/cav/rpc.ts

A server framework for Deno
Go to Latest
import * as mod from "https://deno.land/x/cav@0.0.21/rpc.ts";

Functions

Creates an endpoint handler for resolving Requests into Responses.

Constructs a new RpcInit. This simply returns the first argument, it's only provided for typing purposes so that you don't need to manually specify the types when extracting out an spreadable RpcInit object. Use this to stay DRY.

Interfaces

In Cav, there is no middleware. To fill the gap, Rpcs can leverage Ctx functions to create context-dependent data related to a request. These functions are where you'd set up databases, create session objects, etc. The value returned from this function is available as the ctx property for an Rpc's resolve and resolveError functions.

Arguments available to the Ctx function of an Rpc.

After an Rpc matches with an incoming request, the Resolve function is responsible for resolving the request data into a response to send back to the client. The value returned from the Resolver will be packed with the top-level response() function, i.e. it undergoes packing via packBody().

Arguments available to a Resolver function.

Handler for handling errors that occur during response resolution. Meant to turn the errors into responses to send back to the client, using the same serialization process and utilties available in the resolve function. If an error is re-thrown, that error will be serialized as the response.

Arguments available to the resolveError() function of an Rpc.

Cav's endpoint HTTP handler. Rpcs are one of two fundamental building blocks of Cav server applications, the other being Stacks. Stacks are responsible for routing a request, Rpcs are responsible for handling them.

Initializer options for constructing Rpcs.

Type Aliases

Matches any valid context function. Useful for type constraints.

Alias for an Rpc with any init type. Useful for type constraints.

Matches any RpcInit. Useful for type constraints.