@types/body-parser

  • Version 1.19.2
  • Published
  • 8.3 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

Variables

variable bodyParser

const bodyParser: bodyParser.BodyParser;

    Interfaces

    interface BodyParser

    interface BodyParser {}

      method 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.

      method 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.

      method 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.

      method 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

      call signature

      (options?: OptionsJson & OptionsText & OptionsUrlencoded): NextHandleFunction;
      • Deprecated

        use individual json/urlencoded middlewares

      interface Options

      interface Options {}

        property inflate

        inflate?: boolean | undefined;
        • 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 | undefined;
        • 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) | undefined;
        • 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 | undefined;
          • 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 | undefined;
            • 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 | undefined;
              • 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 | undefined;
              • 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>