@types/send

  • Version 0.17.4
  • Published
  • 9.85 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/send
yarn add @types/send
pnpm add @types/send

Overview

TypeScript definitions for send

Index

Variables

variable mime

const mime: any;

    Functions

    function send

    send: typeof send;
    • Create a new SendStream for the given path to send to a res. The req is the Node.js HTTP request and the path is a urlencoded path to send (urlencoded, not the actual file-system path).

    Interfaces

    interface SendOptions

    interface SendOptions {}

      property acceptRanges

      acceptRanges?: boolean | undefined;
      • Enable or disable accepting ranged requests, defaults to true. Disabling this will not send Accept-Ranges and ignore the contents of the Range request header.

      property cacheControl

      cacheControl?: boolean | undefined;
      • Enable or disable setting Cache-Control response header, defaults to true. Disabling this will ignore the maxAge option.

      property dotfiles

      dotfiles?: 'allow' | 'deny' | 'ignore' | undefined;
      • Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot ("."). Note this check is done on the path itself without checking if the path actually exists on the disk. If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny"). 'allow' No special treatment for dotfiles. 'deny' Send a 403 for any request for a dotfile. 'ignore' Pretend like the dotfile does not exist and 404. The default value is similar to 'ignore', with the exception that this default will not ignore the files within a directory that begins with a dot, for backward-compatibility.

      property end

      end?: number | undefined;
      • Byte offset at which the stream ends, defaults to the length of the file minus 1. The end is inclusive in the stream, meaning end: 3 will include the 4th byte in the stream.

      property etag

      etag?: boolean | undefined;
      • Enable or disable etag generation, defaults to true.

      property extensions

      extensions?: string[] | string | boolean | undefined;
      • If a given file doesn't exist, try appending one of the given extensions, in the given order. By default, this is disabled (set to false). An example value that will serve extension-less HTML files: ['html', 'htm']. This is skipped if the requested file already has an extension.

      property immutable

      immutable?: boolean | undefined;
      • Enable or disable the immutable directive in the Cache-Control response header, defaults to false. If set to true, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed. false

      property index

      index?: string[] | string | boolean | undefined;
      • By default send supports "index.html" files, to disable this set false or to supply a new index pass a string or an array in preferred order.

      property lastModified

      lastModified?: boolean | undefined;
      • Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.

      property maxAge

      maxAge?: string | number | undefined;
      • Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.

      property root

      root?: string | undefined;
      • Serve files relative to path.

      property start

      start?: number | undefined;
      • Byte offset at which the stream starts, defaults to 0. The start is inclusive, meaning start: 2 will include the 3rd byte in the stream.

      interface SendStream

      interface SendStream extends stream.Stream {}

        method error

        error: (status: number, error?: Error) => void;
        • Emit error with status.

        method etag

        etag: (val: boolean) => SendStream;
        • Deprecated

          pass etag as option Enable or disable etag generation.

        method from

        from: (paths: string) => SendStream;
        • Deprecated

          pass root as option Set root path.

        method hasTrailingSlash

        hasTrailingSlash: () => boolean;
        • Check if the pathname ends with "/".

        method headersAlreadySent

        headersAlreadySent: () => void;
        • Raise error that headers already sent.

        method hidden

        hidden: (val: boolean) => SendStream;
        • Deprecated

          use dotfiles option Enable or disable "hidden" (dot) files.

        method index

        index: (paths: string[] | string) => SendStream;
        • Deprecated

          pass index as option Set index paths, set to a falsy value to disable index support.

        method isCachable

        isCachable: () => boolean;
        • Check if the request is cacheable, aka responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}).

        method isConditionalGET

        isConditionalGET: () => boolean;
        • Check if this is a conditional GET request.

        method isFresh

        isFresh: () => boolean;
        • Check if the cache is fresh.

        method isRangeFresh

        isRangeFresh: () => boolean;
        • Check if the range is fresh.

        method maxage

        maxage: (maxAge: string | number) => SendStream;
        • Deprecated

          pass maxAge as option Set max-age to maxAge.

        method notModified

        notModified: () => void;
        • Respond with 304 not modified.

        method onStatError

        onStatError: (error: Error) => void;
        • Handle stat() error.

        method pipe

        pipe: <T extends NodeJS.WritableStream>(res: T) => T;
        • Pipe to res.

        method redirect

        redirect: (path: string) => void;
        • Redirect to path.

        method removeContentHeaderFields

        removeContentHeaderFields: () => void;
        • Strip content-* header fields.

        method root

        root: (paths: string) => SendStream;
        • Deprecated

          pass root as option Set root path.

        method send

        send: (path: string, stat?: fs.Stats) => void;
        • Transfer path.

        method sendFile

        sendFile: (path: string) => void;
        • Transfer file for path.

        method sendIndex

        sendIndex: (path: string) => void;
        • Transfer index for path.

        method setHeader

        setHeader: (path: string, stat: fs.Stats) => void;
        • Set response header fields, most fields may be pre-defined.

        method stream

        stream: (path: string, options?: {}) => void;
        • Transfer index for path.

        method type

        type: (path: string) => void;
        • Set content-type based on path if it hasn't been explicitly set.

        Package Files (1)

        Dependencies (2)

        Dev Dependencies (0)

        No dev dependencies.

        Peer Dependencies (0)

        No peer dependencies.

        Badge

        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/send.

        • Markdown
          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/send)
        • HTML
          <a href="https://www.jsdocs.io/package/@types/send"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>