Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pino-std-serializers

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-std-serializers - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

7

lib/req.js

@@ -58,8 +58,11 @@ 'use strict'

const _req = Object.create(pinoReqProto)
_req.id = typeof req.id === 'function' ? req.id() : req.id
// req.info is for hapi compat.
_req.id = (typeof req.id === 'function' ? req.id() : (req.id || (req.info && req.info.id))) || ''
_req.method = req.method
_req.url = req.url
// req.url.path is for hapi compat.
_req.url = req.url ? (req.url.path || req.url) : undefined
_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

@@ -66,0 +69,0 @@ return _req

{
"name": "pino-std-serializers",
"version": "1.1.0",
"version": "1.2.0",
"description": "A collection of standard object serializers for Pino",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -49,7 +49,9 @@ # pino-std-serializers

{
id: 'string', // Default is an empty string. Attach a synchronous function
// to the input `request` that returns an identifier to have
id: 'string', // Default is an empty string, unless there is an `id` property
// already attached to the `request` object or to the `request.info`
// object. Attach a synchronous function
// to the `request.id` that returns an identifier to have
// the value filled.
method: 'string',
url: 'string',
url: 'string', // the request pathname (as per req.url in core HTTP)
headers: Object,

@@ -56,0 +58,0 @@ remoteAddress: 'string',

@@ -66,2 +66,22 @@ 'use strict'

test('req.raw will be obtained in from input request raw property if input request raw property is truthy', function (t) {
t.plan(2)
var server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.tearDown(() => server.close())
function handler (req, res) {
req.raw = { req: {foo: 'foo'}, res: {} }
var serialized = serializers.reqSerializer(req)
t.ok(serialized.raw)
t.is(serialized.raw.req.foo, 'foo')
res.end()
}
})
test('req.id has a non-function value', function (t) {

@@ -85,2 +105,21 @@ t.plan(1)

test('req.id will be obtained from input request info.id when input request id does not exist', function (t) {
t.plan(1)
var server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.tearDown(() => server.close())
function handler (req, res) {
req.info = {id: 'test'}
var serialized = serializers.reqSerializer(req)
t.is(serialized.id, 'test')
res.end()
}
})
test('req.id has a non-function value with custom id function', function (t) {

@@ -106,2 +145,21 @@ t.plan(2)

test('req.url will be obtained from input request url.path when input request url is an object', function (t) {
t.plan(1)
var server = http.createServer(handler)
server.unref()
server.listen(0, () => {
http.get(server.address(), () => {})
})
t.tearDown(() => server.close())
function handler (req, res) {
req.url = {path: '/test'}
var serialized = serializers.reqSerializer(req)
t.is(serialized.url, '/test')
res.end()
}
})
test('can wrap request serializers', function (t) {

@@ -108,0 +166,0 @@ t.plan(3)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc