Skip to main content
This release is 6 versions behind 17.1.3 — the latest version of @oak/oak. Jump to latest

@oak/oak@16.0.0
Built and signed on GitHub Actions

A middleware framework for handling HTTP with Deno, Node.js, Bun and Cloudflare Workers 🐿️🦕🥟⚙️

This package works with Cloudflare Workers, Node.js, Deno, Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
100%
Published
7 months ago (16.0.0)
interface SendOptions

Options which can be specified when using the send middleware.

Properties

optional
brotli: boolean

Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists. (defaults to true)

optional
contentTypes: Record<string, string>

A record of extensions and content types that should be used when determining the content of a file being served. By default, the media_type database is used to map an extension to the served content-type. The keys of the map are extensions, and values are the content types to use. The content type can be a partial content type, which will be resolved to a full content type header.

Any extensions matched will override the default behavior. Key should include the leading dot (e.g. .ext instead of just ext).

Example

app.use((ctx) => {
  return send(ctx, ctx.request.url.pathname, {
    contentTypes: {
      ".importmap": "application/importmap+json"
    },
    root: ".",
  })
});
optional
extensions: string[]

Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to undefined)

optional
format: boolean

If true, format the path to serve static file servers and not require a trailing slash for directories, so that you can do both /directory and /directory/. (defaults to true)

optional
gzip: boolean

Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. (defaults to true).

optional
hidden: boolean

Allow transfer of hidden files. (defaults to false)

Tell the browser the resource is immutable and can be cached indefinitely. (defaults to false)

optional
index: string

Name of the index file to serve automatically when visiting the root location. (defaults to none)

optional
maxage: number

Browser cache max-age in milliseconds. (defaults to 0)

A size in bytes where if the file is less than this size, the file will be read into memory by send instead of returning a file handle. Files less than the byte size will send an "strong" ETag header while those larger than the bytes size will only be able to send a "weak" ETag header (as they cannot hash the contents of the file). (defaults to 1MiB)

Root directory to restrict file access.

Add Package

deno add jsr:@oak/oak

Import symbol

import { type SendOptions } from "@oak/oak";

---- OR ----

Import directly with a jsr specifier

import { type SendOptions } from "jsr:@oak/oak";

Add Package

npx jsr add @oak/oak

Import symbol

import { type SendOptions } from "@oak/oak";

Add Package

yarn dlx jsr add @oak/oak

Import symbol

import { type SendOptions } from "@oak/oak";

Add Package

pnpm dlx jsr add @oak/oak

Import symbol

import { type SendOptions } from "@oak/oak";

Add Package

bunx jsr add @oak/oak

Import symbol

import { type SendOptions } from "@oak/oak";