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/tracing / src / toReqResMeta.ts
Size: Mime:
import {
  Request as ExpressRequest,
  Response as ExpressResponse,
} from 'express'
import { isObj } from 'exotic'
import { Timer } from './Timer'
import { LoggingMetaType } from './typings'
import { toTracing } from './toTracing'

export const toReqResMeta = (req: ExpressRequest, res: ExpressResponse, timer: Timer): LoggingMetaType => {
  return {
    get timing() {
      if (isObj(timer.endWallTime) === true) {
        return timer.toJSON()
      } else {
        return 'unfinished'
      }
    },
    tracing: toTracing(req),
    meta: {
      bytesReceived: req.get('content-length') as any,
      get bytesSent() {
        return res.getHeader('content-length') as any
      },
    },
    cache: {
      isCached: false,
    },
  }
}