Skip to main content
Home

@oak/oak@17.1.4
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
94%
Published
6 months ago (17.1.4)
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)

optional
immutable: boolean

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)

optional
maxbuffer: number

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: string

Root directory to restrict file access.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

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

pnpm i jsr:@oak/oak
or (using pnpm 10.8 or older)
pnpm dlx jsr add @oak/oak

Import symbol

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

Add Package

yarn add jsr:@oak/oak
or (using Yarn 4.8 or older)
yarn dlx jsr add @oak/oak

Import symbol

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

Add Package

vlt install jsr:@oak/oak

Import symbol

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

Add Package

npx 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";