CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
index.d.ts86 linesDownload Raw Back to raw-body
1declare namespace getRawBody {2  export type Encoding = string | true;3 4  export interface Options {5    /**6     * The expected length of the stream.7     */8    length?: number | string | null;9    /**10     * The byte limit of the body. This is the number of bytes or any string11     * format supported by `bytes`, for example `1000`, `'500kb'` or `'3mb'`.12     */13    limit?: number | string | null;14    /**15     * The encoding to use to decode the body into a string. By default, a16     * `Buffer` instance will be returned when no encoding is specified. Most17     * likely, you want `utf-8`, so setting encoding to `true` will decode as18     * `utf-8`. You can use any type of encoding supported by `iconv-lite`.19     */20    encoding?: Encoding | null;21  }22 23  export interface RawBodyError extends Error {24    /**25     * The limit in bytes.26     */27    limit?: number;28    /**29     * The expected length of the stream.30     */31    length?: number;32    expected?: number;33    /**34     * The received bytes.35     */36    received?: number;37    /**38     * The encoding.39     */40    encoding?: string;41    /**42     * The corresponding status code for the error.43     */44    status: number;45    statusCode: number;46    /**47     * The error type.48     */49    type: string;50  }51}52 53/**54 * Gets the entire buffer of a stream either as a `Buffer` or a string.55 * Validates the stream's length against an expected length and maximum56 * limit. Ideal for parsing request bodies.57 */58declare function getRawBody(59  stream: NodeJS.ReadableStream,60  callback: (err: getRawBody.RawBodyError, body: Buffer) => void61): void;62 63declare function getRawBody(64  stream: NodeJS.ReadableStream,65  options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding,66  callback: (err: getRawBody.RawBodyError, body: string) => void67): void;68 69declare function getRawBody(70  stream: NodeJS.ReadableStream,71  options: getRawBody.Options,72  callback: (err: getRawBody.RawBodyError, body: Buffer) => void73): void;74 75declare function getRawBody(76  stream: NodeJS.ReadableStream,77  options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding78): Promise<string>;79 80declare function getRawBody(81  stream: NodeJS.ReadableStream,82  options?: getRawBody.Options83): Promise<Buffer>;84 85export = getRawBody;86