Skip to main content
Module

x/cav/browser.ts>Client

A server framework for Deno
Go to Latest
type alias Client
import { type Client } from "https://deno.land/x/cav@0.0.14/browser.ts";

A Proxied 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".

The type parameter is the type of the handler this client points to, which allows the Client typescript to extract information about what data the Cav server expects to receive and respond with. Special treatment is given to Stacks and Rpcs. For now, any other type will result in all argument shapes and response types to be unknown.

Type Parameters

optional
T = unknown
definition: (T extends Stack<infer R> ? Client<R> : T extends Rpc<infer R, any, any, infer Q, infer M, infer U> ? Endpoint<R, Q, M, U> : T extends Record<never, never> ? UnionToIntersection<[K in keyof T]: ExpandPath<K, Client<T[K]>>[keyof T]> : unknown)