Skip to main content
Module

x/texa/src/middleware/static.ts>Static

A Deno web framework inspired by Oak and Express. Built-in support for WebSockets, middleware and routing.
Latest
class Static
import { Static } from "https://deno.land/x/texa@0.8.1/src/middleware/static.ts";

A static file server middleware.

Constructors

new
Static(dir: string, options?: { indexes?: string[] | Set<string>; handlers?: Handlers | HandlersMap; vanityExtensions?: string[] | Set<string>; directoryListing?: DirectoryListingFn; })

Initiate a new static file server middleware.

Properties

readonly
dir: string

The directory to serve.

optional
directoryListing: DirectoryListingFn

A function to create a directory listing.

readonly
handlers: HandlersMap

An object of handlers.

indexes: Set<string>

The index names

readonly
vanityExtensions: Set<string>

A set of vanity extensions.

Methods

run(
req: Request,
res: Response,
next: NextFn,
)

Run the middlewares on this static

Static Properties

readonly
startsWithDot: RegExp

Static Methods

fallback(file: string): Promise<[string, string]>

A fallback incase an extension is not found on the static middleware.

findFile(
indexes: Set<string>,
vanityExtensions: Set<string>,
path: string,
throwOnPermissionDenied?: boolean,
): Promise<string | void>

Attempt to find an existing index within a directory.

getEntries(dir: string): Promise<{ size?: number; name: string; }[]>

Get the entries of a directory.