@types/body-parser

  • Version 1.19.0
  • Published
  • 8.01 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/body-parser
yarn add @types/body-parser
pnpm add @types/body-parser

Overview

TypeScript definitions for body-parser

Index

Functions

function bodyParser

bodyParser: typeof bodyParser;
  • Deprecated

function json

json: (options?: OptionsJson) => any;
  • Returns middleware that only parses json and only looks at requests where the Content-Type header matches the type option.

function raw

raw: (options?: Options) => any;
  • Returns middleware that parses all bodies as a Buffer and only looks at requests where the Content-Type header matches the type option.

function text

text: (options?: OptionsText) => any;
  • Returns middleware that parses all bodies as a string and only looks at requests where the Content-Type header matches the type option.

function urlencoded

urlencoded: (options?: OptionsUrlencoded) => any;
  • Returns middleware that only parses urlencoded bodies and only looks at requests where the Content-Type header matches the type option

Interfaces

interface Options

interface Options {}

    property inflate

    inflate?: boolean;
    • When set to true, then deflated (compressed) bodies will be inflated; when false, deflated bodies are rejected. Defaults to true.

    property limit

    limit?: number | string;
    • Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the bytes library for parsing. Defaults to '100kb'.

    property type

    type?: string | string[] | ((req: http.IncomingMessage) => any);
    • The type option is used to determine what media type the middleware will parse

    method verify

    verify: (req: any, res: any, buf: any, encoding: string) => void;
    • The verify option, if supplied, is called as verify(req, res, buf, encoding), where buf is a Buffer of the raw request body and encoding is the encoding of the request.

    interface OptionsJson

    interface OptionsJson extends Options {}

      property strict

      strict?: boolean;
      • When set to true, will only accept arrays and objects; when false will accept anything JSON.parse accepts. Defaults to true.

      method reviver

      reviver: (key: string, value: any) => any;
      • The reviver option is passed directly to JSON.parse as the second argument.

      interface OptionsText

      interface OptionsText extends Options {}

        property defaultCharset

        defaultCharset?: string;
        • Specify the default character set for the text content if the charset is not specified in the Content-Type header of the request. Defaults to utf-8.

        interface OptionsUrlencoded

        interface OptionsUrlencoded extends Options {}

          property extended

          extended?: boolean;
          • The extended option allows to choose between parsing the URL-encoded data with the querystring library (when false) or the qs library (when true).

          property parameterLimit

          parameterLimit?: number;
          • The parameterLimit option controls the maximum number of parameters that are allowed in the URL-encoded data. If a request contains more parameters than this value, a 413 will be returned to the client. Defaults to 1000.

          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/body-parser.

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