x/oak@v9.0.0/mod.ts

A middleware framework for handling HTTP with Deno 🐿️ 🦕
GitHub Stars
4211
Go to latest
import * as oak from "https://deno.land/x/oak@v9.0.0/mod.ts";

Classes

Application

A class which registers middleware (via .use()) and then processes inbound requests against that middleware (via .listen()).

Context

Provides context about the current request and response to middleware functions.

Cookies

An interface which allows setting and accessing cookies related to both the current request and response.

FormDataReader

A class which provides an interface to access the fields of a multipart/form-data body.

HttpError

A base class for individual classes of HTTP errors.

HttpServerNative
HttpServerStd
MultiPartStream

A class that takes a file (either a Deno.File or Uint8Array) and bytes and streams the ranges as a multi-part encoded HTTP body.

NativeRequest
Request

An interface which provides information about the current request.

Response

An interface to control what response will be sent when the middleware finishes processing the request.

Router

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.

ServerSentEvent

An event which contains information which will be sent to the remote connection and be made available in an EventSource as an event.

Enums

Status

HTTP status codes

Variables

httpErrors

An object which contains an individual HTTP Error for each HTTP status error code (4XX and 5XX). When errors are raised related to a particular HTTP status code, they will be of the appropriate instance located on this object. Also, context's .throw() will throw errors based on the passed status code.

REDIRECT_BACK

A symbol that indicates to response.redirect() to attempt to redirect back to the request referrer. For example:

STATUS_TEXT
testing.mockContextState

Allows external parties to modify the context state.

Functions

composeMiddleware

Compose multiple middleware functions into a single middleware function.

etag.calculate

Calculate an ETag value for an entity. If the entity is FileInfo, then the tag will default to a weak ETag. options.weak overrides any default behavior in generating the tag.

etag.factory

Create middleware that will attempt to decode the response.body into something that can be used to generate an ETag and add the ETag header to the response.

etag.getEntity

For a given Context, try to determine the response body entity that an ETag can be calculated from.

etag.ifMatch

A helper function that takes the value from the If-Match header and an entity and returns true if the ETag for the entity matches the supplied value, otherwise false.

etag.ifNoneMatch

A helper function that takes the value from the If-No-Match header and an entity and returns false if the ETag for the entity matches the supplied value, otherwise false.

helpers.getQuery

Given a context, return the .request.url.searchParams as a Map of keys and values of the params.

ifRange

Determine, by the value of an If-Range header, if a Range header should be applied to a request, returning true if it should or otherwise false.

isErrorStatus

Determines if a HTTP Status is an ErrorStatus (4XX or 5XX).

isHttpError
isRedirectStatus

Determines if a HTTP Status is a RedirectStatus (3XX).

parseRange
proxy

Middleware that provides a back-to-back proxy for requests.

send

Asynchronously fulfill a response with a file from the local file system.

testing.createMockApp

Creates a mock of Application.

testing.createMockContext

Create a mock of Context or RouterContext.

testing.createMockNext

Creates a mock next() function which can be used when calling middleware.

Interfaces

ApplicationOptions
BodyOptions
ByteRange
ContextSendOptions
CookiesGetOptions
CookiesSetDeleteOptions
etag.ETagOptions
etag.FileInfo

Just the part of Deno.FileInfo that is required to calculate an ETag, so partial or user generated file information can be passed.

FormDataBody
FormDataReadOptions
ListenOptionsBase
ListenOptionsTls
Middleware

Middleware are functions which are chained together to deal with requests.

ProxyOptions
Route
RouterAllowedMethodsOptions
RouterContext

The context passed router middleware.

RouterMiddleware
RouterOptions
RouterParamMiddleware

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.

SendOptions
ServerConstructor
ServerRequest

An interface that aligns to the parts of std/http/server's ServerRequest that actually is consumed by oak.

ServerResponse

An interface that aligns to what oak returns and is compatible with std/http/server's request.respond().

ServerSentEventInit
ServerSentEventTarget
testing.MockContextOptions

Options that can be set in a mock context.

Type Aliases

Body
BodyBytes
BodyForm
BodyFormData
BodyJson
BodyReader
BodyStream
BodyText
BodyType
BodyUndefined
ErrorStatus

A HTTP status that is an error (4XX and 5XX).

FormDataFile

A representation of a file that has been read from a form data body.

helpers.GetParamsOptions
HTTPMethods
ListenOptions
RedirectStatus

A HTTP status that is a redirect (3XX).

RouteParams
State