strong-tie/inbound-calls
0
1'use strict'2 3module.exports = {4 mapHttpResponse,5 resSerializer6}7 8const rawSymbol = Symbol('pino-raw-res-ref')9const pinoResProto = Object.create({}, {10 statusCode: {11 enumerable: true,12 writable: true,13 value: 014 },15 headers: {16 enumerable: true,17 writable: true,18 value: ''19 },20 raw: {21 enumerable: false,22 get: function () {23 return this[rawSymbol]24 },25 set: function (val) {26 this[rawSymbol] = val27 }28 }29})30Object.defineProperty(pinoResProto, rawSymbol, {31 writable: true,32 value: {}33})34 35function resSerializer (res) {36 const _res = Object.create(pinoResProto)37 _res.statusCode = res.headersSent ? res.statusCode : null38 _res.headers = res.getHeaders ? res.getHeaders() : res._headers39 _res.raw = res40 return _res41}42 43function mapHttpResponse (res) {44 return {45 res: resSerializer(res)46 }47}48 