@abtnode/router-provider 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

router-provider

ABT 节点的路由提供者,包含多个路由引擎实现。

Usage

const { getProvider } = require('router-provider');
const providerName = 'nginx';
const Provider = getProvider(providerName);

const provider = new Provider({ configDir });
provider.start();
provider.stop();
// ...

Run Test

测试分为两部分:通用单元测试和生成的 gateway.spec.js 测试。 这两部分的原因是 gateway.spec.js 有一些端口 & nginx 依赖项。

General unit testing

npm run test

gateway.spec.js

测试依赖docker,所以需要在电脑上安装docker才能开始测试。 gateway.spec.js文件不包含在源代码中,它是在测试过程中生成的,所以如果需要查看该文件,需要手动生成。

pwd
/project/abt-node/core/router-provider
npm run test:generate-gateway

生成的文件在 /project/abt-node/core/router-provider/tests/gateway.spec.js 中。

为了节省资源,这部分测试并没有单独安装依赖,所以需要在项目的heel目录下启动测试:

pwd
/project/abt-node
make test-in-docker

Contribution

你可以通过多种方式为这个包做贡献,比如添加对另一个路由引擎的支持:

  • [ ] Apache
  • [ ] Openresty
  • [ ] Tengine
  • [ ] AWS ELB
  • [ ] Node.js
  • [x] Nginx: supported

如果您正在使用 nginx 路由引擎,您可能会发现这个工具很有用:https://nginx.viraptor.info/

router-provider

The routing provider for ABT Node, which contains several routing engine implementations.

Usage

const { getProvider } = require('router-provider');
const providerName = 'nginx';
const Provider = getProvider(providerName);

const provider = new Provider({ configDir });
provider.start();
provider.stop();
// ...

Run Test

The tests are divided into two parts: the general unit tests and the generated gateway.spec.js tests. The reason for the two parts is that gateway.spec.js has some port & nginx dependencies.

General unit testing

npm run test

gateway.spec.js

The test relies on docker, so you need to have docker installed on your computer to start the test. The gateway.spec.js file is not included in the source code, it is generated during the test, so if you need to see the file, you need to generate it manually.

pwd
/project/abt-node/core/router-provider
npm run test:generate-gateway

The generated file is in /project/abt-node/core/router-provider/tests/gateway.spec.js.

To save resources, this part of the test is not installed separately from the dependencies, so you need to start the test in the project's heel directory:

pwd
/project/abt-node
make test-in-docker

Contribution

There are various ways for you to contribute to this package, such as adding support for another routing engine:

  • [ ] Apache
  • [ ] Openresty
  • [ ] Tengine
  • [ ] AWS ELB
  • [ ] Node.js
  • [x] Nginx: supported

If you are working with the nginx routing engine, you may found this tool useful: https://nginx.viraptor.info/

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文