UNPKG

@teclone/r-server

Version:

A lightweight, extensible web-server with inbuilt routing-engine, static file server, file upload handler, request body parser, middleware support and lots more

48 lines (47 loc) 1.21 kB
/// <reference types="node" /> import { Data, Query } from '../@types/index'; export interface BodyParserConstructOpts { tempDir: string; } export declare class BodyParser { /** * resolves the field name by removing trailing bracket */ private resolveFieldName; /** * stores a file into the given files object */ private assignDataEntry; /** * parses a multipart part headers. */ private parseHeaders; /** * parse multipart form data *@see https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html */ private parseMultiPart; /** * parse json content */ private parseJSON; /** * parse url encoded request body */ private parseUrlEncoded; /** * parse the query parameters in the given url */ parseQueryString(url: string): Query; /** * converts url search parameters to object * @param searchParams * @returns */ urlSearchParamsToObject(searchParams: URLSearchParams): Data; /** *@param {Buffer} buffer - the buffer data *@param {string} contentType - the request content type */ parse(buffer: Buffer, contentType: string): Data; }