raw-body
- Version 3.0.2
- Published
- 18.5 kB
- 4 dependencies
- MIT license
Install
npm i raw-bodyyarn add raw-bodypnpm add raw-bodyOverview
Get and validate the raw body of a readable stream.
Index
Functions
Interfaces
Type Aliases
Functions
function getRawBody
getRawBody: { ( stream: NodeJS.ReadableStream, callback: (err: getRawBody.RawBodyError, body: Buffer) => void ): void; ( stream: NodeJS.ReadableStream, options: | getRawBody.Encoding | (getRawBody.Options & { encoding: getRawBody.Encoding }), callback: (err: getRawBody.RawBodyError, body: string) => void ): void; ( stream: NodeJS.ReadableStream, options: getRawBody.Options, callback: (err: getRawBody.RawBodyError, body: Buffer) => void ): void; ( stream: NodeJS.ReadableStream, options: | getRawBody.Encoding | (getRawBody.Options & { encoding: getRawBody.Encoding }) ): Promise<string>; (stream: NodeJS.ReadableStream, options?: getRawBody.Options): Promise<Buffer>;};Gets the entire buffer of a stream either as a
Bufferor a string. Validates the stream's length against an expected length and maximum limit. Ideal for parsing request bodies.
Interfaces
interface Options
interface Options {}property encoding
encoding?: Encoding | null;The encoding to use to decode the body into a string. By default, a
Bufferinstance will be returned when no encoding is specified. Most likely, you wantutf-8, so setting encoding totruewill decode asutf-8. You can use any type of encoding supported byiconv-lite.
property length
length?: number | string | null;The expected length of the stream.
property limit
limit?: number | string | null;The byte limit of the body. This is the number of bytes or any string format supported by
bytes, for example1000,'500kb'or'3mb'.
interface RawBodyError
interface RawBodyError extends Error {}property encoding
encoding?: string;The encoding.
property expected
expected?: number;property length
length?: number;The expected length of the stream.
property limit
limit?: number;The limit in bytes.
property received
received?: number;The received bytes.
property status
status: number;The corresponding status code for the error.
property statusCode
statusCode: number;property type
type: string;The error type.
Type Aliases
type Encoding
type Encoding = string | true;Package Files (1)
Dependencies (4)
Dev Dependencies (9)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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/raw-body.
- Markdown[](https://www.jsdocs.io/package/raw-body)
- HTML<a href="https://www.jsdocs.io/package/raw-body"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2572 ms. - Missing or incorrect documentation? Open an issue for this package.
