From koajs.com:
app.callback ()Returns a callback function suitable for the http.createServer () method to process the request. You can also use this callback function to mount your koa application in a Connect / Express application.
app.callback ()
Returns a callback function suitable for the http.createServer () method to process the request. You can also use this callback function to mount your koa application in a Connect / Express application.
Now I have an Express application that is already starting its own HTTP server. How to mount a koa application on top of this existing server so that it has the same port?
Would I include a koa application like Express middlware? Do I still use app.callback()for this?
app.callback()
expressapp.use(koaapp.callback()) . , koaapp.callback() next, - koaapp .
expressapp.use(koaapp.callback())
koaapp.callback()
next
, API
var koaapp = koa() var expressapp = express() http.createServer(req, res) { if (true) koaapp(req, res); else expressapp(req, res); })
/prefix, -
/prefix
var http = require('http'); var expressApp = require('express'); var koaApp = require('koa'); // ... expressApp.use('/prefix', http.createServer(koaApp.callback()));