Skip to main content
Module

x/dactyl/deps.ts>Application

Web framework for Deno, built on top of Oak 🦇
Latest
class Application
extends EventTarget
import { Application } from "https://deno.land/x/dactyl@v0.1.0-alpha/deps.ts";

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

The context.state can be typed via passing a generic argument when constructing an instance of Application.

Constructors

new
Application(options?: ApplicationOptions<S>)

Type Parameters

optional
S extends State = Record<string, any>

Properties

keys: KeyStack | Key[] | undefined

A set of keys, or an instance of KeyStack which will be used to sign cookies read and set by the application to avoid tampering with the cookies.

state: S

Generic state of the application, which can be specified by passing the generic argument when constructing:

  const app = new Application<{ foo: string }>();

Or can be contextually inferred based on setting an initial state object:

  const app = new Application({ state: { foo: "bar" } });

Methods

addEventListener(
type: "error",
listener: ApplicationErrorEventListenerOrEventListenerObject<S> | null,
options?: boolean | AddEventListenerOptions,
): void
listen(addr: string): Promise<void>

Start listening for requests, processing registered middleware on each request. If the options .secure is undefined or false, the listening will be over HTTP. If the options .secure property is true, a .certFile and a .keyFile property need to be supplied and requests will be processed over HTTPS.

listen(options: ListenOptions): Promise<void>

Start listening for requests, processing registered middleware on each request. If the options .secure is undefined or false, the listening will be over HTTP. If the options .secure property is true, a .certFile and a .keyFile property need to be supplied and requests will be processed over HTTPS.

use(...middleware: Middleware<S, Context<S>>[]): this

Register middleware to be used with the application.