当前位置:网站首页>Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)

Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)

2022-04-23 19:19:00 "Technology makes customers"

Preface

Many little partners asked me how to add configuration to my company's projects mock, stay vue Everyone in the project knows how to configure mock, In large-scale front-end projects, I was confused .
loEv-hikcahh3016251.jpg

I'll answer him , You'll be here today vue In the project , I changed the company that day with angular、react,webix… wait

Still not configured to use mock, It's recommended easymock,
All front-end projects can be used, whatever you jb frame , It's all done ojbk. Someone asked ,easymock, Why deploy locally , Can't you use it online ?( Of course. , Everything you say is right )

There are several reasons
- 1 easymock The official website often hangs , Cause development progress to stop ( If you can't finish the task, wait for overtime )
- 2 Some partners are outsourcing companies , You can't use the Internet (mmp There is no Internet , How do I Google program ?)
- 3 In case of that day easymock Lost your important information ( It's no use suing him )

Quick start ( The bus to kindergarten is leaving , Get in the car and fasten your seat belt )

Before we start , Suppose you have successfully installed Node.js(>= v8.9)& MongoDB(>= v3.4)& Redis(>= v4.0).

MongoDB Installation tutorial :http://www.runoob.com/mongodb/mongodb-window-install.html

Redis Installation tutorial :http://www.runoob.com/redis/redis-install.html

tips tip

  • node.js and mongodb When installing, it is always next Just go down .
  • redis It's a compressed package , Just unzip it

Check if the installation is successful

  • node.js It works npm It was successful , Or output node edition
  • mongodb Find the installed folder ( Generally, the default is C:\Program Files\MongoDB\Server\4.0\bin Inside ), double-click mongo.exe Input db Carriage return display test The database is successful
    db.png
  • redis Check whether it is successful. See the installation tutorial above for a very simple .

install

$ git clone https://github.com/easy-mock/easy-mock.git
$ cd easy-mock && npm install

The configuration file

find config/default.json, Or create a config/local.json file , Replace the following fields to be replaced with your own configuration .( By default, the configuration file does not need to be modified )

Different environments will load different configuration files , Before that, you should be right node-config Know something about .

{
  "port": 7300,//easymock Project start port 
  "host": "0.0.0.0",
  "pageSize": 30,
  "proxy": false,
  "db": "mongodb://localhost/easy-mock",//  You don't need to create your own database , Starting easymock Just create a new interface 
  "unsplashClientId": "",
  "redis": {
    "port": 6379,//redis port 
    "host": "localhost"
  },
  "blackList": {
    "projects": [], // projectId, example :"5a4495e16ef711102113e500"
    "ips": [] // ip, example :"127.0.0.1"
  },
  "rateLimit": { // https://github.com/koajs/ratelimit
    "max": 1000,
    "duration": 1000
  },
  "jwt": {
    "expire": "14 days",
    "secret": "shared-secret"
  },
  "upload": {
    "types": [".jpg", ".jpeg", ".png", ".gif", ".json", ".yml", ".yaml"],
    "size": 5242880,
    "dir": "../public/upload",
    "expire": {
      "types": [".json", ".yml", ".yaml"],
      "day": -1
    }
  },
  "fe": {
    "copyright": "",
    "storageNamespace": "easy-mock_",
    "timeout": 25000,
    "publicPath": "/dist/"
  }
}

start-up

$ npm run dev
#  visit  http://127.0.0.1:7300

run.png

At this time, we can open an interface preview at random , Copy url use postman Test interface ok

mock.png

More requirements configuration , See the official website for details , I don't want more Once said .

Vue Study Group 493671066, Many beauties . Old driver, get in the car , It's too late to explain .

Author correlation Vue article

be based on Vue2.0 Realize the authority control of background system

vue2.0- be based on elementui Skin peeler [ Custom theme ]

Front end document summary

VUE2.0 Add, delete, change, check, attach, edit, add model( bounced ) Component sharing

Reward Heartfelt thanks

 Reward

版权声明
本文为["Technology makes customers"]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210559121080.html