
var wreq   = require('watchify-request')
var assert = require('assert')

module.exports = kw

// Wrap `watchify-request` in koa middleware.
// @param  {Function} bundler
// @return {GeneratorFunction}
// @api public
function kw(bundler) {
  assert(typeof bundler, 'function')
  var handler = wreq(bundler)
  return function *watchifyRequest(next) {
    handler(this.req, this.res, function(err, body) {
      if (err) this.throw(err)
      this.response.body = body
    }.bind(this))
  }
}

const wreq = require('watchify-request')
const assert = require('assert')

module.exports = kw

// Wrap `watchify-request` in koa middleware.
// @param {Function} bundler
// @return {Function*}
// @api public
function kw(bundler) {
  assert.equal(typeof bundler, 'function')
  var handler = wreq(bundler)
  return function *watchifyRequest(next) {
    const res = yield handler.bind(handler, this.req, this.res)
    if (res[0]) this.throw(err)
    this.response.body = res[1]
    yield next
  }
}

fix logic