import * as cav from "https://deno.land/x/cav@0.0.24/mod.ts";
Variables
Signed cookies are HS256 JWTs with the header omitted to keep the cookies small. To inspect the cookies as regular JWTs, this header needs to be prepended to the cookie value with a period separator. Like this: | |
Serves HTTP requests with the given handler. (Stacks and Rpcs 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. |
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. | |
Constructs a new Client function tied to the base URL. The provided set of serializers will be used everywhere that data is de/serialized when using this client, including web sockets. | |
Creates a new CookieJar instance for managing a Request's cookies. | |
Verifies the JWT and returns its parsed payload object. If verification fails, an error will be thrown. Verification will fail if: | |
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. | |
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 using the provided schema and resolver function. The schema properties will be assigned to the returned endpoint function, with the resolve argument available as the "resolve" property. | |
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. See https://book.hacktricks.xyz/pentesting-web/deserialization/nodejs-proto-prototype-pollution for more information on prototype poisoning. | |
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 | |
Bundles every bundle.ts(x) or *_bundle.ts(x) file in the folder into an
adjacent file with the same name plus a .js suffix, recursively. The bundles
will be compiled with | |
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 ".", 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. | |
Hook for getting routing metadata from a Request. If there isn't already a
RouterContext associated with the Request, a new one will be generated. The
same RouterContext object is returned on every subsequent call to
| |
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. | |
Response factory for serving static assets. Asset resolution uses the provided ServeAssetOptions, the Request is only used for caching headers like ETag etc. | |
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 | |
Stops watching an assets directory that was prepared with | |
Prepares the assets directory and watches it for changes to the ts(x) bundles or their dependencies. When a change occurs, the bundles will be rebuilt. | |
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
Initializer options for creating an | |
Object denoting the location of an assets directory. | |
Arguments available to Context functions. | |
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. | |
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 Response will deserialize into. | |
Options for processing requests, used to construct Endpoints. | |
Init options for constructing HttpErrors, which can expose arbitrary data and status codes during de/serialization. | |
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 function of an endpoint. | |
Arguments available to a ResolveError function. | |
Metadata object for caching and tracking information about how a Request has been routed so far in the handling process. | |
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. | |
Type constraint for the type parameter of a RouterRequest. The shape describes the client property accesses that would result in a valid endpoint call. The endpoints are specified by their handler definitions. | |
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. | |
A server socket handler can use this Request type to ferry type information to the client about the valid socket send/receive message types and acceptable query string parameters for the initial request. | |
Schema options for creating a | |
A version of the Client type without E2E type safety. | |
ClientArg but without any type information. These are the arguments when the type for the client function isn't known. | |
Options for the | |
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. | |
Type that matches any socket. Useful for type constraints. | |
Client function that wraps a | |
Arguments for the client function when its internal path points to an endpoint. | |
Type constraint for the Client's type parameter. | |
Type utility for extracting the output of a "ctx" function on an EndpointSchema or SocketSchema. | |
Cav Endpoint handler, for responding to requests. | |
Type utility for extracting the output of a "groups" parser on an EndpointSchema or SocketSchema. | |
Record representing path groups captured during routing. | |
Generic handler type for server-defined Request handlers. | |
Type utility for extracting the output of a "message" parser on an EndpointSchema or SocketSchema. | |
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. | |
Type utility for extracting the output of a "query" parser on an EndpointSchema or SocketSchema. | |
Record representing query string parameters. | |
Cav Router handlers, for routing requests. | |
Type utility for extracting the type of message a socket expects to send from a SocketSchema. | |
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. | |
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. |