Repository URL to install this package:
|
Version:
2.0.12 ▾
|
//todo @anto this one needs to be moved to uxui-component library
const log = require('fliplog')
function fromReqResToDebug(req) {
const {
protocol,
secure,
ip,
ips,
subdomains,
path,
hostname,
host,
xhr,
body,
cookies,
method,
params,
query,
route,
signedCookies,
originalUrl,
url,
baseUrl,
locals,
charset,
headersSent,
_header,
headers,
rawHeaders,
data,
statusCode,
status,
statusText,
} = req
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 nonCircular
}
function fromReqAndResToDebug(arg) {
const req = fromReqResToDebug(arg.req)
const res = fromReqResToDebug(arg.res)
return { req, res }
}
function fromReqAndOrResToDebug(arg) {
if (arg.req) {
return fromReqAndResToDebug(arg)
} else {
return fromReqResToDebug(arg)
}
}
function logReqAndOrRes(arg) {
if (process.env.SHOULD_LOG_REQ_RES || true) {
const formatted = fromReqAndOrResToDebug(arg)
// const asString = JSON.stringify(formatted, undefined, 2)
log
.data(formatted)
.bold('[uxui-apis] request')
.echo()
}
}
export { fromReqResToDebug }
export { fromReqAndResToDebug }
export { logReqAndOrRes }