Node.js 膝关节炎应用程序可以使用另一个膝关节炎应用吗?
正如问题所示,我在使用一个Node.js 膝关节炎应用程序可以使用另一个膝关节炎应用吗?,node.js,middleware,koa,Node.js,Middleware,Koa,正如问题所示,我在使用一个koa应用程序作为另一个应用程序的中间件时遇到了问题。使用express,我们可以: const express = require('express'); const expressApp = express(); const otherExpressApp = express(); app.use(otherExpressApp); 同样的模式也适用于connect。但是,它不能与koa一起工作: const koa = require(`koa`); cons
koa
应用程序作为另一个应用程序的中间件时遇到了问题。使用express
,我们可以:
const express = require('express');
const expressApp = express();
const otherExpressApp = express();
app.use(otherExpressApp);
同样的模式也适用于connect
。但是,它不能与koa一起工作:
const koa = require(`koa`);
const koaApp = koa();
const otherKoaApp = koa();
app.use(otherKoaApp);
给我:
AssertionError: app.use() requires a generator function
at Application.app.use (/home/sean/repos/koaka/node_modules/koa/lib/application.js:100:5)
at repl:1:5
at REPLServer.defaultEval (repl.js:164:27)
at bound (domain.js:250:14)
at REPLServer.runBound [as eval] (domain.js:263:12)
at REPLServer.<anonymous> (repl.js:392:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:546:8)
但这似乎不适用于koa本身:
koaApp.use(otherKoaApp.callback());
抛出:
AssertionError: app.use() requires a generator function
at Application.app.use (/home/sean/repos/koaka/node_modules/koa/lib/application.js:100:5)
at repl:1:7
at REPLServer.defaultEval (repl.js:164:27)
at bound (domain.js:250:14)
at REPLServer.runBound [as eval] (domain.js:263:12)
at REPLServer.<anonymous> (repl.js:392:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:546:8)
AssertionError:app.use()需要一个生成器函数
在Application.app.use(/home/sean/repos/koaka/node_modules/koa/lib/Application.js:100:5)
回复:1:7
在REPLServer.defaultEval(repl.js:164:27)
绑定时(domain.js:250:14)
在REPLServer.runBound[as eval](domain.js:263:12)
在服务器上。(回复js:392:12)
在emitOne(events.js:82:20)
在REPLServer.emit上(events.js:169:7)
在REPLServer.Interface.\u在线(readline.js:210:10)
在REPLServer.Interface.\u行(readline.js:546:8)
我可以使用一个
koa
应用程序作为另一个koa
应用程序的中间件吗?如果可以,如何使用?如果没有,是否打算在将来的版本中使用此行为?为什么或者为什么不?实现这一点的方法是使用koa挂载
或者,将其装载到URL子路径下:
app1.use(mount('/api', app2));
koa与express的不同之处在于它的内核非常小。例如,快递船采用静态WebServer中间件,但膝关节炎并不。事实上,你需要导入一个单独的模块来做“X”,这只是膝关节炎手术的方法。但是请注意,koa挂载
仍在旗舰koajs github repo之下,因此它或多或少是官方的。实现这一点的方法是使用koa挂载
或者,将其装载到URL子路径下:
app1.use(mount('/api', app2));
koa与express的不同之处在于它的内核非常小。例如,快递船采用静态WebServer中间件,但膝关节炎并不。事实上,你需要导入一个单独的模块来做“X”,这只是膝关节炎手术的方法。但是请注意,koa挂载
仍在旗舰koajs github repo之下,因此它或多或少是官方的。实现这一点的方法是使用koa挂载
或者,将其装载到URL子路径下:
app1.use(mount('/api', app2));
koa与express的不同之处在于它的内核非常小。例如,快递船采用静态WebServer中间件,但膝关节炎并不。事实上,你需要导入一个单独的模块来做“X”,这只是膝关节炎手术的方法。但是请注意,koa挂载
仍在旗舰koajs github repo之下,因此它或多或少是官方的。实现这一点的方法是使用koa挂载
或者,将其装载到URL子路径下:
app1.use(mount('/api', app2));
koa与express的不同之处在于它的内核非常小。例如,快递船采用静态WebServer中间件,但膝关节炎并不。事实上,你需要导入一个单独的模块来做“X”,这只是膝关节炎手术的方法。但是请注意,koa mount
仍在旗舰koajs github repo之下,因此它或多或少是官方的