dino-express
Version:
DinO enabled REST framework based on express
41 lines (40 loc) • 1.68 kB
TypeScript
import { type EnvironmentConfiguration } from 'dino-core';
import { type Request } from 'express';
import { type GenericObject } from '../Types';
/**
* Parses the request body.
*
*/
export declare class RequestBodyParser {
private readonly environment;
/**
* Create a new instance of RequestBodyParser
* @param {EnvironmentConfiguration} environment the environment configuration
*/
constructor(environment: EnvironmentConfiguration);
/**
* Parse the body of the received request. Set forceBase64Decode to true will cause inspection
* and deciding as required of the top level properties of the received message, if the
* received message contains the property isBase64Encoded this will take precedence above the
* configuration settings.
*
* @param {Request} req the express request
* @returns {object} the parsed body
*/
parse(req: Request | GenericObject, method?: string, def?: GenericObject): GenericObject | string;
/**
* Customisable hook that allows to extract the body from the received request
* @param {Request} req the received request
* @returns {any} the request body
* @protected
*/
protected extractBody(req: Request | GenericObject, method?: string, def?: GenericObject): GenericObject | string;
/**
* Parse the request body decoding base64 string if present
* @param {any} body the request body
* @param {string[]} base64RequestDecodePaths an array of object pats that define the base64 strings to decode
* @returns {any} the parsed and decoded request body
* @private
*/
private parseAndDecodeFromBase64;
}