Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/cav/serial.ts

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

Classes

Error class for describing exceptions during HTTP processing.

Functions

Deserializes a JSON value that was serialize()d back into the original input. An error will be thrown if a value was serialized with an unknown serializer.

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.

Serializes a new Request, which can then be deserialized using unpack(). Only GET and POST requests are supported; the method used is automatically determined based on the presence of the body init option.

Serializes a new Response, which can then be deserialized back into the input body using unpack().

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.

Deserializes a Request generated with packRequest() back into the original request body. Any serializers specified during packing need to be specified here as well.

Interfaces

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 client will know what type it'll return when it's unpacked.

Initializer options when creating a Request with packRequest().

Interface for serializing and deserializing arbitrary non-JSON primitive values into JSON.

Options for the unpack() function.

Type Aliases

Type alias representing a Serializer with any input or output type. Useful for type constraints.

Init options for packing/serializing data into a PackedResponse.

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.

Calculates the type returned when unpacking a PackedResponse.