• 项目共享协调机制


     

    API,协调前端与后端开发的连接点。

    面临几个问题

    1. API更新不及时,导致前端开发的接口没有及时更新而出现各种问题。

    2. 文档描述得不准确

    3. 没有统一的标准。

    我们可以使用swagger editor, swagger ui。第一是编辑器,第二个是展示,部署用的。

     

    在ubuntu 使用

    先下载代码,然后用npm安装http-server

    git clone https://github.com/swagger-api/swagger-editor.git

    sudo  npm install -g http-server

     

    http-server –p 2008 swagger-editor

    执行上面的命令行在有可能出现错误,提示说 env里面没有node的命令,那是由于ubuntu使用了apt-get安装了node,为了避免包名冲突,重命名了node。执行下面的命令可以解决这个问题。

    sudo ln -s /usr/bin/nodejs /usr/bin/node

     

     

    至于swagger-ui,我们创建一个文件夹,比如mkdir node_app

    git clone https://github.com/swagger-api/swagger-ui.git 到swagger文件里面

     

     npm init

     npm install express --save

     sudo npm install express --save

     cp -R  ~/swagger/swagger-ui/dist  public

     

    上面步骤初始化了npm,然后把一些资源文件复制的到一个新建的目录public,然后修改index.js

    var express = require('express');
    var app = express();
    app.use('/static', express.static('public'));
    app.get('/', function (req, res) {
          res.send('Hello World!');
    });
    
    
    app.listen(3001, function () {
          console.log('Example app listening on port 3001!');
    });

    执行这个命令行,就会启动一个监听端口3001的服务

    node index.js

     

    执行命令测试,马上返回结果

    curl localhost:3001    

    Hello World!

     

    访问路径即可使用网站:

    localhost:3001/static/index.html

     

     

     


     

    自己搭建了一个gogs的git网上

    可以创建一个镜像,可以创建自己的私有的库。可以创建web hook

     

     

  • 相关阅读:
    ASP.NET WEB API 自定义模型校验过滤器
    使用asp.net mvc部分视图渲染html
    .Net中的并行编程-7.基于BlockingCollection实现高性能异步队列
    python爬虫技术的选择
    优雅的处理异常
    解决asp.net动态压缩
    .Net中的并行编程-6.常用优化策略
    使用快捷键提升C#开发效率
    .Net中的并行编程-5.流水线模型实战
    .Net中的并行编程-4.实现高性能异步队列
  • 原文地址:https://www.cnblogs.com/studyNT/p/7745235.html
Copyright © 2020-2023  润新知