pino-std-serializers
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -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) |
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
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
15220
375
97
2