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

koa-compose

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-compose - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

91

index.js

@@ -1,8 +0,2 @@

/**
* Module dependencies.
*/
var debug = require('debug')('koa-compose');
var fmt = require('util').inspect;
/**

@@ -12,5 +6,3 @@ * Expose compositor.

module.exports = debug.enabled
? instrumented
: compose;
module.exports = compose;

@@ -43,83 +35,2 @@ /**

/**
* Compose `middleware` returning
* an instrumented set of middleware
* for debugging manipulation between
* continuation.
*
* @param {Array} middleware
* @return {Function}
* @api public
*/
function instrumented(middleware){
console.warn('Warning: do not run DEBUG=koa-compose in production');
console.warn('as it will greatly affect the performance of your');
console.warn('application - it is designed for a development');
console.warn('environment only.\n');
return function *(next){
var i = middleware.length;
var prev = next || noop();
var name = prev._name || prev.name || 'noop';
var curr;
while (i--) {
curr = middleware[i];
prev = wrap.call(this, curr, prev, name);
name = curr._name || curr.name;
}
yield *prev;
}
}
/**
* Wrap to output debugging info.
*
* @api private
*/
function wrap(curr, prev, name) {
return curr.call(this, function *(next){
if ('noop' == name) return yield next;
this._level = this._level || 0;
// downstream
output(this, 'down', name);
// yield
this._level++;
yield next;
this._level--;
// upstream
output(this, 'up', name);
}.call(this, prev));
}
/**
* 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.

@@ -126,0 +37,0 @@ *

6

package.json

@@ -5,3 +5,3 @@ {

"repository": "koajs/compose",
"version": "2.2.0",
"version": "2.3.0",
"keywords": [

@@ -15,5 +15,3 @@ "koa",

],
"dependencies": {
"debug": "*"
},
"dependencies": {},
"devDependencies": {

@@ -20,0 +18,0 @@ "co": "~3.0.1",

@@ -12,18 +12,4 @@

## Debugging
To debug the interactions between middleware, you may use
the __DEBUG__ environment variable, for example:
```
$ DEBUG=koa-compose node --harmony app.js
```
When enabled this will output verbose response information and the
middleware names to help visualize how they interact.
![koa middleware debugging](https://dl.dropboxusercontent.com/u/6396913/koa/Screen%20Shot%202013-12-22%20at%208.46.46%20AM.png)
## License
MIT
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