Skip to main content
Module

x/cav/mod.ts>Client

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

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

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 server expects to receive and respond with.

Type Parameters

optional
T extends
| Handler[]
| null
= null
definition: (T extends Handler[] ? Client<T[number]> : T extends (req: RouterRequest<infer S>, ...a: any[]) => Response | Promise<Response> ? Client<S> : T extends (req: EndpointRequest<infer Q, infer M, infer U>, ...a: any[]) => EndpointResponse<infer R> | Promise<EndpointResponse<infer R>> ? (x: ClientArg<Q, M, U>) => Promise<R extends Socket<infer S, infer M2> ? Socket<M2, S> : R> : T extends RouterShape ? UnionToIntersection<[K in keyof T]: ExpandPath<K, Client<T[K]>>[keyof T]> : (x: ClientArg<any, any, any>) => Promise<unknown>)