{"action":"created","issue":{"url":"https://api.github.com/repos/koajs/koa/issues/846","repository_url":"https://api.github.com/repos/koajs/koa","labels_url":"https://api.github.com/repos/koajs/koa/issues/846/labels{/name}","comments_url":"https://api.github.com/repos/koajs/koa/issues/846/comments","events_url":"https://api.github.com/repos/koajs/koa/issues/846/events","html_url":"https://github.com/koajs/koa/issues/846","id":185834864,"number":846,"title":"mounting into an express app","user":{"login":"nickb1080","id":3442934,"avatar_url":"https://avatars.githubusercontent.com/u/3442934?v=3","gravatar_id":"","url":"https://api.github.com/users/nickb1080","html_url":"https://github.com/nickb1080","followers_url":"https://api.github.com/users/nickb1080/followers","following_url":"https://api.github.com/users/nickb1080/following{/other_user}","gists_url":"https://api.github.com/users/nickb1080/gists{/gist_id}","starred_url":"https://api.github.com/users/nickb1080/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickb1080/subscriptions","organizations_url":"https://api.github.com/users/nickb1080/orgs","repos_url":"https://api.github.com/users/nickb1080/repos","events_url":"https://api.github.com/users/nickb1080/events{/privacy}","received_events_url":"https://api.github.com/users/nickb1080/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-28T04:11:41Z","updated_at":"2016-10-28T04:48:42Z","closed_at":null,"body":"I'm exploring migrating a large production Express app to koa v2 (so all of this applies to the promise API of v2). The koajs.com docs say for `app.callback()`: \r\n\r\n> \"You may also use this callback function to mount your koa app in a Connect/Express app.\" \r\n\r\nHowever, it seems like you must mount a koa app at the \"bottom\" of your Express app since koa will never call `next()` to yield control back to express (like in the 404 case). I can't see an obvious work around for this currently. If the function returned by `callback` returned the promise, I think something like the following would work:\r\n\r\n```js\r\nconst koaCallback = koaApp.callback();\r\nexpressApp.use(function (req, res, next) {\r\n  koaCallback(req, res)\r\n    .then(function () {\r\n      // not sure exactly how to detect this but seems doable\r\n      if (!koaSentResponse(res)) {\r\n        next() // let express keep processing this request\r\n      }\r\n   });\r\n});\r\n```\r\n\r\nPerhaps somewhat related -- what's the use case for setting `ctx.respond` to `false`? "},"comment":{"url":"https://api.github.com/repos/koajs/koa/issues/comments/256835543","html_url":"https://github.com/koajs/koa/issues/846#issuecomment-256835543","issue_url":"https://api.github.com/repos/koajs/koa/issues/846","id":256835543,"user":{"login":"PlasmaPower","id":6006498,"avatar_url":"https://avatars.githubusercontent.com/u/6006498?v=3","gravatar_id":"","url":"https://api.github.com/users/PlasmaPower","html_url":"https://github.com/PlasmaPower","followers_url":"https://api.github.com/users/PlasmaPower/followers","following_url":"https://api.github.com/users/PlasmaPower/following{/other_user}","gists_url":"https://api.github.com/users/PlasmaPower/gists{/gist_id}","starred_url":"https://api.github.com/users/PlasmaPower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PlasmaPower/subscriptions","organizations_url":"https://api.github.com/users/PlasmaPower/orgs","repos_url":"https://api.github.com/users/PlasmaPower/repos","events_url":"https://api.github.com/users/PlasmaPower/events{/privacy}","received_events_url":"https://api.github.com/users/PlasmaPower/received_events","type":"User","site_admin":false},"created_at":"2016-10-28T04:48:42Z","updated_at":"2016-10-28T04:48:42Z","body":"It looks like `ctx.respond = false` might be useful after all. Try making your first middleware `return next().then(() => ctx.respond = (ctx.body == null));` or similar (double equal sign as `undefined == null` but `'' != null`)."}}
{"actor":{"display_login":"PlasmaPower"}}