diff --git a/debugging/index.js b/debugging/index.js new file mode 100644 index 0000000..fb3b888 --- /dev/null +++ b/debugging/index.js @@ -0,0 +1,37 @@ + +/** + * Module dependencies. + */ + +var koa = require('koa'); +var app = koa(); + +// to enable debugging output per middleware +// run with the following environment variable: +// $ DEBUG=koa-compose node --harmony debugging + +// note how the function names are used +// in the debug output. + +app.use(function *json(next){ + yield next; + this.body = { message: this.body }; +}); + +app.use(function *reverse(next){ + yield next; + this.set('X-Bar', 'baz'); + this.body = this.body.split('').reverse().join(''); +}); + +app.use(function *uppercase(next){ + yield next; + this.set('X-Foo', 'bar'); + this.body = this.body.toUpperCase(); +}); + +app.use(function *response(next){ + this.body = 'Hello World' +}); + +app.listen(3000); \ No newline at end of file