import * as cav from "https://deno.land/x/cav@0.2.3/mod.ts";
Functions
Creates an Endpoint for serving static assets. The routed request path will be used to find the asset to serve from inside the assets directory specified. | |
Creates an endpoint for serving a TypeScript or JavaScript bundle. The bundle is cached into memory and will be watched and rebundled whenever updated, if possible. | |
Creates a new client function for making requests to remote Cav handlers. If the type of the handler is provided and it's a Cav handler, the client will have end-to-end typesafety turned on. | |
Hook for getting routing metadata from a Request. If there isn't already a
Context associated with the Request, a new one will be generated. The same
Context object is returned on every subsequent call to | |
Creates a new CookieJar instance for managing a Request's cookies. | |
f cx | Filters out any non-string or empty string arguments and joins the rest to create a class list for an HTML element. |
Decodes a signed cookie. If no keys are provided, the fallback keys will be used. If the cookie can't be decoded, an error will be thrown. | |
Verifies the JWT and returns its parsed payload object. If verification fails, an error will be thrown. | |
Deserializes a JSON value that was | |
Checks if the Response is a "did match" Response, i.e. the handler it came from wants this Response to be returned to the client. | |
Encodes a signed cookie. | |
Creates a new JWT with the given payload, which is passed into JSON.stringify before encoding. If no key is specified, a securely random transient fallback will be used. The fallback key is only generated once during startup and it's lost when the Deno process quits. | |
Constructs a new Endpoint request handler. The schema properties will be assigned to the returned endpoint function, so that they can be reused on other endpoint schemas. | |
Determines if the object is a plain object or not. This also checks for prototype poisoning; it returns false whenever the prototype of an input object was poisoned before JSON.parsing it. | |
Adds a Symbol to the Response to indicate to any containing Routers that the handler didn't match with the Request. The Router will continue looking for matches. | |
Normalizes a Parser into a ParserFunction. | |
Serializes a new Request, which can then be deserialized using
| |
Serializes a new Response, which can then be deserialized back into the input
body using | |
Creates an Endpoint that always redirects. The "path" schema option is "/", i.e. the whole request path should have been consumed by the containing router(s) before the request reaches a redirect endpoint. If the redirect path doesn't specify an origin, the origin of the request is used. If the path starts with a "./" or a "../", it's joined with the pathname of the Request url to get the final redirect path. The default status is 302. | |
Constructs a new Router handler using the provided routes. The route properties are also available on the returned Router function. | |
Serializes a value recursively until it's JSON-compatible. Serializers can be plugged in to extend the accepted types beyond what Cav supports by default. If a value isn't recognized by any of the provided or default serializers, an error will be thrown. | |
Constructs a Serializer. This simply returns the first argument, it's only used for type annotations. | |
Serves HTTP requests with the given handler. (Routers and Endpoints are handlers.) You can specify an object with a port and hostname option, which is the address to listen on. The default is port 8000 on hostname "0.0.0.0". This is a re-export of the serve() function from https://deno.land/std/http/server.ts. | |
Response factory for serving static assets. Asset resolution uses the provided ServeAssetOptions, the Request is only used for caching headers like ETag etc. | |
Response factory for bundling and serving TypeScript and JavaScript files. Bundled files are cached into memory and watched for changes, if possible. When a change occurs, the cached bundle is invalidated. The request is only used for caching headers. | |
Constructs a new server instance. This is a simple function wrapper around the Server constructor from https://deno.land/std/http/server.ts. | |
Constructs a new Socket request handler using the provided schema and setup function. The schema properties will be assigned to the returned socket endpoint function, with the setup argument available as the "setup" property. | |
Deserializes a Request generated with | |
Wraps a WebSocket instance with added serialization functionality and E2E type support. If the input is a string, the wrapped WebSocket will be created with the given URL. |
Interfaces
Object denoting the location of an assets directory. | |
Arguments for the Client function. | |
Settings used to initialize a | |
Metadata object for caching and tracking information about how a Request has been routed so far in the handling process. | |
Options for deleting a cookie from a CookieJar. | |
Interface for reading and updating the cookies for a Request. Supports cookie
signing. Most operations are synchronous, with the exception of
| |
Options for setting a cookie in a CookieJar. | |
Arguments available to Context functions. | |
A server endpoint handler can use this Request type to ferry type information to the client about what argument types are acceptable and what the result will be into. | |
Options for processing requests, used to construct Endpoints. | |
Arguments available to a ResolveError function. | |
Init options for constructing HttpErrors, which can expose arbitrary data and status codes during de/serialization. | |
Request type that tracks its content-type just like PackedResponse. | |
Response type that tracks its content-type so the | |
Initializer options when creating a Request with | |
A function that parses data. If data is not shaped as expected, an error should be thrown. | |
An object with a ParserFunction as its "parse" property. Zod compatible. | |
Arguments available to the resolve of an endpoint. | |
A server router handler can use this Request type to ferry type information to the client about what routes exist and what data they accept/return. The client uses the RouterShape to infer which property accesses are valid and what their response type will be. | |
Interface for serializing and deserializing arbitrary non-JSON primitive values into JSON. | |
Options controlling how assets are found and served. | |
Arguments available to the setup function of a socket endpoint. | |
Schema options for creating a | |
Options for the | |
I WS | Isomorphic WebSocket interface with JSON serialization and typed messages. |
Initializer options for the |
Type Aliases
Type alias representing a Serializer with any input or output type. Useful for type constraints. | |
Initializer options for creating an | |
Initializer options for creating a | |
Client function for making requests to a remote Cav handler. If the handler type is a Router or Endpoint, end-to-end type safety kicks in. | |
Information about the connection a request arrived on. This is a re-export of the ConnInfo type from https://deno.land/std/http/server.ts. | |
Cav Endpoint handler, for responding to requests. | |
Type of a Client when the handler is an Endpoint. | |
The shape of an EndpointRequest, holding the type information needed to calculate the allowable ClientArgs. | |
Generic handler type for server-defined Request handlers. | |
Init options for packing/serializing data into a PackedResponse. | |
Record representing path parameters captured during routing. | |
An object or function responsible for parsing data or throwing errors if the
data isn't shaped as expected. These can either be functions with a single
data argument that return the parsed data or an object with a | |
Extracts the input type of a given Parser. | |
Extracts the output type of a given Parser. | |
Record representing query string parameters. | |
Cav Router handlers, for routing requests. | |
Type of a Client when the handler is a Router. | |
The shape of a RouterRequest, mapping allowed routes to their handlers. | |
A group of named Serializer objects. Serializer keys are used to tag serialized values on the output JSON, which is required in order to correctly deserialize the value on the other side. | |
Options for serving an http handler. This is a re-export of the ServeInit type from https://deno.land/std/server.ts. | |
An http server. This is a re-export of the Server type from https://deno.land/std/http/server.ts. | |
Options for running an http server. This is a re-export of the ServerInit type from https://deno.land/std/http/server.ts. | |
Cav endpoint handler for connecting web sockets. | |
Type of a Client when the handler isn't a Router or Endpoint. | |
Calculates the type returned when unpacking a PackedResponse. | |
Listener for a Socket's "close" event. | |
Listener for a web socket's "error" event. | |
Listener for a web socket's "message" event. The message is deserialized from the event data. | |
Listener for a Socket's "open" event. |