@types/raw-body
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -14,15 +14,42 @@ // Type definitions for raw-body 2.1 | ||
export interface Options { | ||
length?: number; | ||
limit?: number; | ||
encoding?: Encoding; | ||
/** | ||
* The length of the stream. If the contents of the stream do not add up to this length, an 400 error code is returned. | ||
*/ | ||
length?: number | string | null; | ||
/** | ||
* The byte limit of the body. This is the number of bytes or any string format supported by `bytes`, for example `1000`, `'500kb'` or `'3mb'`. If the body ends up being larger than this limit, a `413` error code is returned. | ||
*/ | ||
limit?: number | string | null; | ||
/** | ||
* The encoding to use to decode the body into a string. By default, a `Buffer` instance will be returned when no encoding is specified. Most likely, you want `utf-8`, so setting encoding to `true` will decode as `utf-8`. You can use any type of encoding supported by `iconv-lite`. | ||
*/ | ||
encoding?: Encoding | null; | ||
} | ||
export interface RawBodyError extends Error { | ||
/** | ||
* The limit in bytes. | ||
*/ | ||
limit?: number; | ||
/** | ||
* The expected length of the stream. | ||
*/ | ||
length?: number; | ||
expected?: number; | ||
/** | ||
* The received bytes. | ||
*/ | ||
received?: number; | ||
/** | ||
* The invalid encoding. | ||
*/ | ||
encoding?: string; | ||
/** | ||
* The corresponding status code for the error. | ||
*/ | ||
status: number; | ||
statusCode: number; | ||
/** | ||
* Either `entity.too.large`, `request.aborted`, `request.size.invalid`, `stream.encoding.set`, or `encoding.unsupported`. | ||
*/ | ||
type: string; | ||
@@ -32,3 +59,5 @@ } | ||
/** | ||
* Gets the entire buffer of a stream either as a `Buffer` or a string. Validates the stream's length against an expected length and maximum limit. Ideal for parsing request bodies. | ||
*/ | ||
declare function getRawBody(stream: Readable, callback: (err: getRawBody.RawBodyError, body: Buffer) => void): void; | ||
@@ -35,0 +64,0 @@ declare function getRawBody(stream: Readable, options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding, callback: (err: getRawBody.RawBodyError, body: string) => void): void; |
{ | ||
"name": "@types/raw-body", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "TypeScript definitions for raw-body", | ||
@@ -17,4 +17,4 @@ "license": "MIT", | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "073253b457ea9fff7ffefd40e846bcaa1996935f05be8d746b4864333d44ddad", | ||
"typesPublisherContentHash": "0371de1695352073d1c9798af875d70e551cc329edabfc5614d3703a84e6e6d9", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Wed, 25 Jan 2017 01:42:29 GMT | ||
* Last updated: Tue, 07 Feb 2017 20:01:00 GMT | ||
* Dependencies: stream, node | ||
@@ -14,0 +14,0 @@ * Global values: none |
@@ -27,5 +27,5 @@ { | ||
"hasPackageJson": false, | ||
"contentHash": "073253b457ea9fff7ffefd40e846bcaa1996935f05be8d746b4864333d44ddad" | ||
"contentHash": "0371de1695352073d1c9798af875d70e551cc329edabfc5614d3703a84e6e6d9" | ||
}, | ||
"isLatest": true | ||
} |
5003
89