Skip to main content
Module

x/reno/reno/builtins.ts

A thin, testable routing library designed to sit on top of Deno's standard HTTP module
Latest
import * as reno from "https://deno.land/x/reno@v2.0.105/reno/builtins.ts";

Functions

A response creator function for building JSON responses, that: defaults the Content-Type header to "application/json"; and serialises the JSON body to a string that's then encoded as a Uint8Array

A response creator function for building stream responses. This one currently doesn't do anything special, but it at least saves the effort of having to create response objects manually, and in the future may contain some sort of enhancing behaviour

Assigns the provided cookies to the underlying Response instance, which are then sent to the requestor via multiple Set-Cookie headers:

A higher-order function that takes a route handler function and returns another route handler that parses form data bodies before invoking the inner handler. The data is parsed internally by creating a URLSearchParams instance, which is then passed to the inner handler via the body prop of the first argument:

A higher-order function that takes a route handler function and returns another route handler that parses JSON bodies before invoking the inner handler:

Type Aliases

A ProcessedRequest with a body type reflecting a URLSearchParams instance.

A ProcessedRequest that allows the body type to be specified via the sole type parameter. Defaults to an empty object.

An AugmentedRequest with an additional property containing the body after it has been parsed or processed, typically by one of the built-in middlewares. For example, the withJsonBody() middleware will deserialise the raw body with JSON.parse() and assign the result to the parsedBody property before forwarding the ProcessedRequest to the wrapped route handler.