koa-compose
Advanced tools
Comparing version 2.1.0 to 2.2.0
41
index.js
@@ -1,2 +0,1 @@ | ||
/** | ||
@@ -62,3 +61,3 @@ * Module dependencies. | ||
var prev = next || noop(); | ||
var name = prev.name || 'noop'; | ||
var name = prev._name || prev.name || 'noop'; | ||
var curr; | ||
@@ -69,3 +68,3 @@ | ||
prev = wrap.call(this, curr, prev, name); | ||
name = curr.name; | ||
name = curr._name || curr.name; | ||
} | ||
@@ -89,6 +88,3 @@ | ||
// downstream | ||
console.log(' \033[1m%d | \033[0m>> \033[36m%s\033[0m', this._level, name); | ||
console.log(); | ||
console.log(fmt(this.response, { depth: 5, colors: true }).replace(/^/gm, ' ')); | ||
console.log(); | ||
output(this, 'down', name); | ||
@@ -101,6 +97,3 @@ // yield | ||
// upstream | ||
console.log(' \033[1m%d | \033[0m<< \033[36m%s\033[0m', this._level, name); | ||
console.log(); | ||
console.log(fmt(this.response, { depth: 5, colors: true }).replace(/^/gm, ' ')); | ||
console.log(); | ||
output(this, 'up', name); | ||
}.call(this, prev)); | ||
@@ -110,2 +103,26 @@ } | ||
/** | ||
* Output debugging information. | ||
*/ | ||
function output(ctx, direction, name) { | ||
direction = 'up' == direction ? '<<' : '>>'; | ||
console.log(' \033[1m%d \033[0m%s \033[36m%s\033[0m', ctx._level, direction, name); | ||
console.log(' \033[90mstatus\033[0m: %s %s', ctx.status, ctx.response.statusString); | ||
console.log(' \033[90mheader\033[0m:'); | ||
header(ctx); | ||
console.log(' \033[90mbody\033[0m: %j', ctx.body); | ||
console.log(); | ||
} | ||
/** | ||
* Output header fields. | ||
*/ | ||
function header(ctx) { | ||
for (var key in ctx.response.header) { | ||
console.log(' \033[90m%s\033[0m: %s', key, ctx.response.header[key]); | ||
} | ||
} | ||
/** | ||
* Noop. | ||
@@ -116,2 +133,2 @@ * | ||
function *noop(){} | ||
function *noop(){} |
@@ -5,3 +5,3 @@ { | ||
"repository": "koajs/compose", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"keywords": [ | ||
@@ -22,3 +22,3 @@ "koa", | ||
"should": "~2.1.0", | ||
"koa": "~0.1.2" | ||
"koa": "~0.3.0" | ||
}, | ||
@@ -25,0 +25,0 @@ "scripts": { |
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
3645
105