Repository URL to install this package:
|
Version:
1.2.16 ▾
|
import { Request, Response } from 'express'
/**
* @todo needs some remaining props you can get by like .getHeaders() for example
*/
function fromReqResToDebug(reqOrRes: Request | Response) {
const { locals, charset, headersSent, status } = reqOrRes as Response
const { _header, data, statusText } = reqOrRes as any
const {
protocol,
secure,
ip,
ips,
subdomains,
path,
hostname,
host,
xhr,
body,
cookies,
method,
params,
query,
route,
signedCookies,
originalUrl,
url,
baseUrl,
headers,
statusCode,
} = reqOrRes as Request
const nonCircular = {
headers,
data,
statusCode,
status,
statusText,
_header,
protocol,
secure,
ip,
ips,
subdomains,
path,
hostname,
host,
xhr,
body,
cookies,
method,
params,
query,
route,
signedCookies,
originalUrl,
url,
baseUrl,
// res
headersSent,
locals,
charset,
}
return JSON.stringify(nonCircular, undefined, 2)
}
export { fromReqResToDebug }