Deployment record of front-end and back-end separation development tool YAPI

The company said before that it would establish a separate development model for front and back ends, but I just graduated, so I was responsible for establishing this specification. Although I have just graduated and have not been to a large factory, it is a challenge for me. Online programs are set up. I searched a lot of projects on Google and github, and finally found a good tool . As long as it is built on the intranet, it can perfectly solve some shortcomings of the separate development of the front and back ends. Build it below

1. Build Yapi database mongo

Direct docker command to start

docker run -d \
  -p 27017:27017 \
  --name mongo \
  --restart=always \
  -v /data/mongo:/data/db \
  -e MONGO_INITDB_ROOT_USERNAME=mongo \
  -e MONGO_INITDB_ROOT_PASSWORD=123456 \
  mongo

img.png

2. Custom configuration file yapi-config.json

mkdir /data/yapi
vim /data/yapi/yapi-config.json

Fill in the configuration (change the account password yourself)

{
    
    
  "port": "3000",
  "adminAccount": "[email protected]",
  "timeout": 120000,
  "db": {
    
    
    "servername": "mongo",
    "DATABASE": "yapi",
    "port": 27017,
    "user": "mongo",
    "pass": "123456",
    "authSource": "admin"
  }
}

3. Initialize the YAPI database index and administrator account

docker run -it --rm \
  --link mongo:mongo \
  --entrypoint npm \
  --workdir /yapi/vendors \
  -v /data/yapi/yapi-config.json:/yapi/config.json \
  registry.cn-hangzhou.aliyuncs.com/anoyi/yapi \
  run install-server

record password

img_1.png

4. Start the Yapi service

docker run -d \
  --name yapi \
  --restart=always \
  --link mongo:mongo \
  --workdir /yapi/vendors \
  -p 9999:3000 \
  -v /data/yapi/yapi-config.json:/yapi/config.json \
  registry.cn-hangzhou.aliyuncs.com/anoyi/yapi \
  server/app.js

img_2.png

5. Visit ip:9999 to log in to view

img_3.png img_4.png

6. New project, interface test

img_5.png img_6.pngJust find any json, paste it and save it

img_7.png

Automatically generate json, click mock to viewimg_8.png img_9.png

7. Summary

This tool is more suitable for simulating basic json. Advantages: It can generate corresponding formats by pasting various json, supports export and import, and supports many plug-ins . You can check it on the github document, and the supported plug-ins are quite complete. Disadvantage: It is necessary to manually change the simulation content, such as Chinese, time, etc.

YApi visual interface management platform

Experience address:

http://yapi.smart-xwork.cn/

Documentation:

hellosean1025.github.io/yapi

Platform Introduction

img_10.png

YApi is an efficient, easy-to-use, and powerful API management platform designed to provide developers, products, and testers with more elegant interface management services. It can help developers easily create, publish, and maintain APIs. YApi also provides users with an excellent interactive experience. Developers only need to use the interface data writing tools provided by the platform and simple click operations to realize interface management.

characteristic

  • Based on Json5 and Mockjs, define the structure and documents of the data returned by the interface, which improves the efficiency by multiple times
  • Flat permission design not only ensures the management of large enterprise-level projects, but also ensures ease of use
  • Interface debugging similar to postman
  • Automated testing, support assertion on Response
  • In addition to supporting ordinary random mocks, MockServer also adds the Mock expectation function, which returns expected data according to the set request filtering rules
  • Support postman, har, swagger data import
  • Free and open source, intranet deployment , no more fear of information leakage

Intranet deployment

Environmental requirements

  • nodejs(7.6+)
  • mongodb(2.6+)
  • git

Install

Using the yapi-cli tool we provide, it is very easy to deploy the YApi platform. Execute the yapi server to start the visual deployment program, enter the corresponding configuration and click to start the deployment, and the deployment of the entire website can be completed. After the deployment is complete, follow the prompts to execute node/{site path/server/app.js} to start the server. Open the specified url in the browser, click Login and enter the administrator email address you just set, and the default password is ymfe.org to log in to the system (the default password can be modified in the personal center).

npm install -g yapi-cli --registry https://registry.npm.taobao.org
yapi server

service management

Use pm2 to facilitate service management and maintenance.

npm install pm2 -g  //安装pm2
cd  {项目目录}
pm2 start "vendors/server/app.js" --name yapi //pm2管理yapi服务
pm2 info yapi //查看服务信息
pm2 stop yapi //停止服务
pm2 restart yapi //重启服务

upgrade

It is very easy to upgrade the project version, and will not affect the existing project data, only the source code files in the vendors directory will be synchronized.

cd  {项目目录}
yapi ls //查看版本号列表
yapi update //更新到最新版本
yapi update -v {Version} //更新到指定版本

tutorial

YApi plugin

code generation

YApi docker deployment (unofficial)

YApi some tools

Some clients of YApi

  • where to
  • Ctrip
  • ELong
  • meituan
  • baidu
  • Tencent
  • alibaba
  • Jingdong
  • Today's headlines
  • VipPay
  • Lianjia.com
  • quick worker
  • convenience bee
  • Zhongshanghuimin
  • Sina
  • VIPS
  • Hornet's nest
  • companion fish
  • Megvii Technology

This article was originally created by " Cheng Ge Blog " and complies with the CC 4.0 BY-SA copyright agreement. For reprinting, please attach the original source link and this statement.
Original text link: front-end and back-end separation development tool YAPI deployment record

Guess you like

Origin blog.csdn.net/Rakers1024/article/details/128082245