Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/react-server / src / deps / fromReqResToDebug.ts
Size: Mime:
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 }