restify
Advanced tools
Comparing version 9.0.0-rc.2 to 9.0.0-rc.3
@@ -7,3 +7,3 @@ 'use strict' | ||
}); | ||
/* | ||
const req = http.request({ | ||
@@ -30,18 +30,19 @@ hostname: 'localhost', | ||
}); | ||
req.end() | ||
*/ | ||
// req.end() | ||
const req = http.request({ | ||
hostname: 'localhost', | ||
port: 8080, | ||
path: '/', | ||
// agent, | ||
// method: 'POST', | ||
}); | ||
req.flushHeaders(); | ||
setTimeout(() => req.destroy(), 50); | ||
// const req = http.request({ | ||
// hostname: 'localhost', | ||
// port: 8080, | ||
// path: '/', | ||
// agent, | ||
// // method: 'POST', | ||
// }); | ||
// | ||
// req.flushHeaders(); | ||
// setTimeout(() => req.destroy(), 50); | ||
setTimeout(() => {}, 5000); | ||
// req.end(); |
@@ -76,8 +76,27 @@ 'use strict'; | ||
assert.func(handler); | ||
var handlerId = handler._identifier || handler._name || handler.name; | ||
if (handler.length <= 2) { | ||
// arity <= 2, must be AsyncFunction | ||
assert.equal(handler.constructor.name, 'AsyncFunction'); | ||
assert.equal( | ||
handler.constructor.name, | ||
'AsyncFunction', | ||
`Handler [${handlerId}] is missing a third argument (the ` + | ||
'"next" callback) but is not an async function. Middleware ' + | ||
'handlers can be either async/await or callback-based.' + | ||
'Callback-based (non-async) handlers should accept three ' + | ||
'arguments: (req, res, next). Async handler functions should ' + | ||
'accept maximum of 2 arguments: (req, res).' | ||
); | ||
} else { | ||
// otherwise shouldn't be AsyncFunction | ||
assert.notEqual(handler.constructor.name, 'AsyncFunction'); | ||
assert.notEqual( | ||
handler.constructor.name, | ||
'AsyncFunction', | ||
`Handler [${handlerId}] accepts a third argument (the 'next" ` + | ||
'callback) but is also an async function. Middleware ' + | ||
'handlers can be either async/await or callback-based. Async ' + | ||
'handler functions should accept maximum of 2 arguments: ' + | ||
'(req, res). Non-async handlers should accept three ' + | ||
'arguments: (req, res, next).' | ||
); | ||
} | ||
@@ -84,0 +103,0 @@ |
@@ -263,7 +263,11 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved. | ||
var log = opts.log.child({ | ||
audit: true, | ||
component: opts.event, | ||
serializers: serializers | ||
}); | ||
var log = opts.log.child( | ||
{ | ||
audit: true, | ||
component: opts.event | ||
}, | ||
{ | ||
serializers: serializers | ||
} | ||
); | ||
@@ -270,0 +274,0 @@ function audit(req, res, route, err) { |
@@ -69,3 +69,7 @@ // Copyright 2012 Mark Cavage, Inc. All rights reserved. | ||
}); | ||
req.log = log.child(props, props.serializers ? false : true); | ||
const childOptions = {}; | ||
if (props.serializers) { | ||
childOptions.serializers = props.serializers; | ||
} | ||
req.log = log.child(props, childOptions); | ||
@@ -72,0 +76,0 @@ if (props.req_id) { |
@@ -208,2 +208,4 @@ 'use strict'; | ||
handler._identifier = `${handler._name} on ${opts.method} ${opts.path}`; | ||
// Attach to middleware chain | ||
@@ -210,0 +212,0 @@ chain.add(handler); |
@@ -77,3 +77,3 @@ { | ||
], | ||
"version": "9.0.0-rc.2", | ||
"version": "9.0.0-rc.3", | ||
"repository": { | ||
@@ -80,0 +80,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
838431
72
8276