///
import { Request, Response } from 'express';
export declare const ContentTypes: {
TEXT_PLAIN: string;
APPLICATION_FORM: string;
APPLICATION_JSON: string;
};
export interface RequestLog {
url: string;
request: {
method: string;
headers: any;
host: string;
clientIp: string;
payload: any;
};
respone: {
headers: any;
status: number;
payload: any;
};
latency: number;
}
export interface ERCIRequest extends Request {
_headers: any;
}
export interface ERCIResponse extends Response {
_headers: any;
write: any;
end: any;
once: any;
}
/**
*
* @param {string} contentType req.get('content-type')
* @param {Request} req
* @param {Response} res
* @param { [key: number|string]: any } options
* @returns Promise< string | { [key: number|string]: any }> the parsed body
*/
export declare function parseRequestBody(contentType: string | undefined, req: ERCIRequest, res: ERCIResponse, options: any): Promise;
/**
* @dependancy: called after parseRequestBody
* @param res Express.Response
* @param options { [key: number|string]: any }
* @return Promise the parsed body
*/
export declare function parseResponseBody(res: ERCIResponse, options: any, next: () => any): Promise;
/**
* @dependancy: called after parseResponseBody
* @param req {Express.Request}
* @returns Promise< string | { [key: number|string]: any }> the parsed body
*/
export declare function parseUrl(req: Request): string;
/**
* @dependancy: called after parseResponseBody
* @param req {Express.Request}
* @returns { method: string, headers: { [key: string]: string|number }, host: string, clientIp: string }
*/
export declare function parseRequestMeta(req: Request): {
method: string;
headers: {
[key: string]: any;
};
host: string | undefined;
clientIp: string | string[];
};
/**
* @dependancy: called after parseResponseBody
* @param res {Express.Response}
* @returns { status: string, headers: { [key: string]: string|number } }
*/
export declare function parseResponseMeta(res: ERCIResponse): {
headers: any;
status: number;
};
/**
* the middleware entry
* @param {*} req
* @param {*} res
* @param {*} next
* @return Promise
*/
export declare function capture(req: ERCIRequest, res: ERCIResponse, next: () => any): Promise;