Skip to main content
Module

x/cav/client.ts

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

Functions

Constructs a new Client tied to a given base URL. The provided set of packers will be used everywhere that data is packed/unpacked when using this client, including web sockets.

Wraps a regular WebSocket with serializer functionality and type support.

Interfaces

An endpoint handler can use this Request type to ferry type information to the client from the server about what client arguments are acceptable.

Response type used to ferry the type of the deserialized response to the client from the server. If a server handler doesn't return this type, the response type of the corresponding client call will be "unknown".

A router handler on the server can use this Request type to ferry type information about valid routes to the client. The client uses the provided RouterShape to infer which property accesses are valid.

Type constraint for the Shape parameter of a RouterRequest. The shape describes the client property accesses that would result in a valid endpoint call.

Cav's WebSocket wrapper interface.

Initializer options to use when upgrading a request into a web socket using the upgradeWebSocket function.

Type Aliases

Type that matches any socket. Useful for type constraints.

A function that wraps fetch() with a tailored process for making requests to a Cav server. Each property access on the function itself returns a new Client that extends the URL of the original Client. The periods represent path dividers and the accessed properties are path segments, like this: client("http://localhost/base").nested["pa.th"]() will result in a request to "http://localhost/base/nested/pa.th".

Arguments for the client function when its internal path points to an endpoint.

Generic handler type for server-defined Request handlers.

Type for a web socket event listener. The shape of the listener depends on the event type. For the "message" event, the message type may be provided as the second type parameter.