1api 中文文档教程

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

1api

一次创建多个 api 服务器

Getting Started

  1. 方法

const oneApi = require('1api');

// Only a http server
const myApi = new oneApi({http: true});

// Add route
myApi.get('/welcome', (req, res) =>
    {
        console.log(req.apiMethod); // "HTTP" or "WS"
        res.status(200).send("Welcome to this module!");
    });

// create server and listen on port 3000
myApi.createServer(3000);
  1. 一种 index.js</

  2. code> 在浏览器中打开 localhost:3000/welcome,您应该会看到:Welcome to this module!

Running the tests

所有测试都在测试文件夹中,可以使用 npm test 运行。 //TODO: 添加一个带有 http 服务器和 websocket 服务器的通用测试

Coding style

//TODO: 添加编码风格

Built With

  • NodeJS (only tested on Node v6.9.5 and should work with all newer versions)
  • Mocha and chai for testing

Contributing

请阅读 [CONTRIBUTING.md]() 以了解我们的行为准则的详细信息,以及向我们提交拉取请求的过程。 //TODO:创建 CONTRIBUTING.md

Versions

0.0.1

  • Initial commit
  • Basic http- and websocket-server

Authors

License

此项目已获得 GNU 通用公共许可证 v3.0 许可 - 有关详细信息,请参阅 LICENSE 文件

1api

One way to create multiple api servers at once

Getting Started

  1. npm install --save 1api

  2. Make a basic file called index.js with the following code:

const oneApi = require('1api');

// Only a http server
const myApi = new oneApi({http: true});

// Add route
myApi.get('/welcome', (req, res) =>
    {
        console.log(req.apiMethod); // "HTTP" or "WS"
        res.status(200).send("Welcome to this module!");
    });

// create server and listen on port 3000
myApi.createServer(3000);
  1. Start de server with node index.js

  2. Open localhost:3000/welcome in the browser and you should see: Welcome to this module!.

Running the tests

All the tests are in the test folder and can be run with npm test. //TODO: Add a general test with http server and websocket server

Coding style

//TODO: Add coding style

Built With

  • NodeJS (only tested on Node v6.9.5 and should work with all newer versions)
  • Mocha and chai for testing

Contributing

Please read [CONTRIBUTING.md]() for details on our code of conduct, and the process for submitting pull requests to us. //TODO: Create CONTRIBUTING.md

Versions

0.0.1

  • Initial commit
  • Basic http- and websocket-server

Authors

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details

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