我正在设计一个基于loopBack的WEB app,它的架构类似于这个:

除了前端应用程序之外,此服务器还应为多个不同的客户端系统提供服务。每个外部系统将有自己的REST API可用,具有不同的资源,身份验证等。我想将这些"REST域“整齐地分开。
我希望所有这些API都有不同的路由,如下所示:
base-url/前端(这很简单) base-url/system-1/.....base-url/system-2/.....
在LoopBack中做这件事最干净的方法是什么?
应用程序中的loopBack模型都是在同一位置创建的,我只能指定它们的名称。有没有办法更改模型的默认URL?如果我在两个系统中都有一个同名的模型,该怎么办?
发布于 2016-09-09 14:23:32
如果基本url与的基本url相同,则通过使用环回路由器实现此目的的一种方法
module.exports = function (app) {
var router = app.loopback.Router();
router.get('/frontend/some-api', function (req, res) {
// you can call your model method responsible to serve this request
}
router.get('/system-1/some-api', function (req, res) {
// you can call your model method responsible to serve this request
}
router.get('/system-2/some-api', function (req, res) {
// you can call your model method responsible to serve this request
}
}https://stackoverflow.com/questions/39394888
复制相似问题