pino-std-serializers
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -56,5 +56,5 @@ 'use strict' | ||
function reqSerializer (req) { | ||
var connection = req.connection | ||
// req.info is for hapi compat. | ||
var connection = req.info || req.connection | ||
const _req = Object.create(pinoReqProto) | ||
// req.info is for hapi compat. | ||
_req.id = (typeof req.id === 'function' ? req.id() : (req.id || (req.info ? req.info.id : undefined))) | ||
@@ -61,0 +61,0 @@ _req.method = req.method |
{ | ||
"name": "pino-std-serializers", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A collection of standard object serializers for Pino", | ||
@@ -34,4 +34,4 @@ "main": "index.js", | ||
"standard": "^11.0.0", | ||
"tap": "^11.1.1" | ||
"tap": "^12.0.0" | ||
} | ||
} |
@@ -204,1 +204,77 @@ 'use strict' | ||
}) | ||
test('req.remoteAddress will be obtained from request connect.remoteAddress as fallback', 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.connection = {remoteAddress: 'http://localhost'} | ||
var serialized = serializers.reqSerializer(req) | ||
t.is(serialized.remoteAddress, 'http://localhost') | ||
res.end() | ||
} | ||
}) | ||
test('req.remoteAddress will be obtained from request info.remoteAddress if available', 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 = {remoteAddress: 'http://localhost'} | ||
var serialized = serializers.reqSerializer(req) | ||
t.is(serialized.remoteAddress, 'http://localhost') | ||
res.end() | ||
} | ||
}) | ||
test('req.remotePort will be obtained from request connect.remotePort as fallback', 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.connection = {remotePort: 3000} | ||
var serialized = serializers.reqSerializer(req) | ||
t.is(serialized.remotePort, 3000) | ||
res.end() | ||
} | ||
}) | ||
test('req.remotePort will be obtained from request info.remotePort if available', 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 = {remotePort: 3000} | ||
var serialized = serializers.reqSerializer(req) | ||
t.is(serialized.remotePort, 3000) | ||
res.end() | ||
} | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17542
449
3