Skip to main content
Module

x/cav/http.ts>ServeAssetOptions

A server framework for Deno
Go to Latest
interface ServeAssetOptions
import { type ServeAssetOptions } from "https://deno.land/x/cav@0.0.8/http.ts";

Options controlling how assets are found and served.

Properties

optional
cwd: string

Sets the current working directory when looking for assets. If a file:// path is provided, the parent folder of the path is used. This is useful if you want to serve assets relative to the current file using import.meta.url. Default: "."

optional
dir: string

The directory to serve assets from inside the cwd. Default: "assets"

path: string

Path of the file to serve relative to the dir (which is relative to the cwd). The full path of the file on disk can be conceptualized as denoPath.join(cwd, dir, path). This option is required, and should typically be equal to the "path" property on the ResolverArg of an Rpc's Resolver function or on the OnErrorArg inside an error handler.

optional
indexes: string[]

When a requested path resolves to a directory and one of these files is found inside that directory, that file will be served instead of a 404 error. Default: ["index.html"]

optional
tryExtensions: string[]

When a requested file isn't found, each of these extensions will be appended to the request path and checked for existence. If the request path plus one of these extensions is found, that file will be served instead of a 404 error. Default: ["html"]

optional
path404: string

Path to use when the provided path results in a 404 error. Use this to serve a 404 page. If this isn't specified, 404 errors will bubble. Default: undefined

optional
bundlers: Bundler[]

Once a request's on-disk file path is calculated, the file path will be passed through each of these provided bundlers. If a bundler returns a Response, that Response will be served instead of the on-disk file and the bundling process is halted. Bundlers are responsible for their own caching techniques. If no array is specified, files are served as-is from disk. Default: undefined