foxx dependecies(4)

在foxx中有两种依赖,分别是模块依赖和foxx服务依赖。

1、模块依赖

我们可以使用node_modules文件夹来安装foxx服务兼容的包。

在foxx中只能是同步的,所以依赖promise等异步行为将不被支持。另外foxx也不支持其他语言扩展,仅支持纯javascript.

2、foxx依赖

foxx依赖可以在manifest.json中进行声明。

"provides": {
  "@foxx/auth": "1.0.0"
}

  

"dependencies": {
  "mySessions": "@foxx/sessions:^2.0.0",
  "myAuth": {
    "name": "@foxx/auth",
    "version": "^1.0.0",
    "description": "This description is entirely optional.",
    "required": false
  }
}

  

服务必须挂摘到相同的数据库,才能够共享依赖。

// Entry file of Service A
module.exports = {
  sayHi () {
    return 'Hello';
  }
};

// Somewhere in Service B
const greeter = module.context.dependencies.greeter;
res.write(greeter.sayHi());

  

posted @ 2018-09-20 13:53  tutu_python  阅读(120)  评论(0)    收藏  举报