import * as superoak from "https://deno.land/x/superoak@4.8.1/test/deps.ts";
A middleware framework for handling HTTP with Deno.
oak works well on both Deno CLI and Deno deploy, and is inspired by koa. It works well with both the Deno CLI and Deno Deploy.
Example server
A minimal router server which responds with content on /
. With Deno CLI
this will listen on port 8080 and on Deploy, this will simply serve requests
received on the application.
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const router = new Router();
router.get("/", (ctx) => {
ctx.response.body = `<!DOCTYPE html>
<html>
<head><title>Hello oak!</title><head>
<body>
<h1>Hello oak!</h1>
</body>
</html>
`;
});
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
app.listen({ port: 8080 });
Namespaces
N etag | A collection of oak specific APIs for management of ETags. |
A collection of APIs to help assist in creating middleware. | |
A collection of utility APIs which can make testing of an oak application easier. |
Classes
A class which registers middleware (via | |
Provides context about the current request and response to middleware
functions, and the current instance being processed is the first argument
provided a | |
Provides an way to manage cookies in a request and response on the server as a single iterable collection, as well as the ability to sign and verify cookies to prevent tampering. | |
An interface which provides an interface to access the fields of a
| |
The base class that all derivative HTTP extend, providing a | |
The oak abstraction of the Deno native HTTP server which is used internally for handling native HTTP requests. Generally users of oak do not need to worry about this class. | |
A class that takes a file (either a Deno.FsFile or Uint8Array) and bytes and streams the ranges as a multi-part encoded HTTP body. | |
An internal oak abstraction for handling a Deno native request. Most users of oak do not need to worry about this abstraction. | |
An interface which provides information about the current request. The
instance related to the current request is available on the
| |
An interface to control what response will be sent when the middleware finishes processing the request. | |
An interface for registering middleware that will run when certain HTTP methods and paths are requested, as well as provides a way to parameterize parts of the requested path. | |
An event which contains information which will be sent to the remote
connection and be made available in an |
Variables
A namespace that contains each error constructor. Each error extends
| |
A symbol that indicates to | |
A record of all the status codes text. | |
Allows external parties to modify the context state. |
Functions
Compose multiple middleware functions into a single middleware function. | |
A factory function which provides a way to create errors. It takes up to 3
arguments, the error | |
Return the directory path of a | |
Calculate an ETag for an entity. When the entity is a specific set of data it will be fingerprinted as a "strong" tag, otherwise if it is just file information, it will be calculated as a weak tag. | |
Create middleware that will attempt to decode the response.body into
something that can be used to generate an | |
For a given Context, try to determine the response body entity that an ETag can be calculated from. | |
A helper function that takes the value from the | |
A helper function that takes the value from the | |
Given a context, return the | |
Determine, by the value of an | |
A type guard that determines if the status code is an error. | |
Determine if a port is available for using
Requires | |
A type guard that determines if the value is an HttpError or not. | |
A type guard that determines if the status code is a redirection. | |
f join | Join all given a sequence of |
Middleware that provides a back-to-back proxy for requests. | |
f send | Asynchronously fulfill a response with a file from the local file system. |
Creates a mock of | |
Create a mock of | |
Creates a mock |
Interfaces
Available options that are used when creating a new instance of
| |
Options which can be used when accessing the | |
When setting the | |
Just the part of | |
When reading a body in full via | |
A representation of a file that has been read from a form data body. Based
on the | |
Options which impact how the form data is decoded for a
| |
Middleware are functions which are chained together to deal with requests. | |
Middleware objects allow encapsulation of middleware along with the ability to initialize the middleware upon listen. | |
The context passed router middleware. | |
Middleware that will be called by the router when handling a specific parameter, which the middleware will be called when a request matches the route parameter. | |
Options that can be set in a mock context. |
Type Aliases
The tagged type for | |
The tagged type for | |
The tagged type for | |
The tagged type for | |
The tagged type for | |
The tagged type for | |
The tagged type for | |
The type of the body, where: | |
The tagged type for | |
An HTTP status that is an error (4XX and 5XX). | |
A type representing string literals of each of the common HTTP method. | |
Type that represents | |
T Next | A function for chaining middleware. |
An HTTP status that is a redirect (3XX). | |