Files
klz-cables.com/.pnpm-store/v10/files/84/b9fcaf02c0ac85c9a6ab6b9c05fb412e95997f877e00b18442f44388d96d1b61a139d36b87e6680ac9eac83d83b9b8e798ed90f55eec6b149a70651c3a4165
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

101 lines
1.9 KiB
Plaintext

'use strict'
module.exports = {
mapHttpRequest,
reqSerializer
}
const rawSymbol = Symbol('pino-raw-req-ref')
const pinoReqProto = Object.create({}, {
id: {
enumerable: true,
writable: true,
value: ''
},
method: {
enumerable: true,
writable: true,
value: ''
},
url: {
enumerable: true,
writable: true,
value: ''
},
query: {
enumerable: true,
writable: true,
value: ''
},
params: {
enumerable: true,
writable: true,
value: ''
},
headers: {
enumerable: true,
writable: true,
value: {}
},
remoteAddress: {
enumerable: true,
writable: true,
value: ''
},
remotePort: {
enumerable: true,
writable: true,
value: ''
},
raw: {
enumerable: false,
get: function () {
return this[rawSymbol]
},
set: function (val) {
this[rawSymbol] = val
}
}
})
Object.defineProperty(pinoReqProto, rawSymbol, {
writable: true,
value: {}
})
function reqSerializer (req) {
// req.info is for hapi compat.
const connection = req.info || req.socket
const _req = Object.create(pinoReqProto)
_req.id = (typeof req.id === 'function' ? req.id() : (req.id || (req.info ? req.info.id : undefined)))
_req.method = req.method
// req.originalUrl is for expressjs compat.
if (req.originalUrl) {
_req.url = req.originalUrl
} else {
const path = req.path
// path for safe hapi compat.
_req.url = typeof path === 'string' ? path : (req.url ? req.url.path || req.url : undefined)
}
if (req.query) {
_req.query = req.query
}
if (req.params) {
_req.params = req.params
}
_req.headers = req.headers
_req.remoteAddress = connection && connection.remoteAddress
_req.remotePort = connection && connection.remotePort
// req.raw is for hapi compat/equivalence
_req.raw = req.raw || req
return _req
}
function mapHttpRequest (req) {
return {
req: reqSerializer(req)
}
}