preface

Many friends ask me how to add configuration mock in their own company’s project. I know how to configure mock in vue project, but I feel confused in large front-end project.

I said, you will use it in vUE project today, angular, React, Webix… , etc.

Easymock is recommended. All front-end projects can use whatever JB framework you have. Ojbk will handle all of them. With EasyMock, why deploy it locally, but not online? (Sure, you’re right about everything)

The reasons are the

  • 1 EasyMock website hangs frequently, resulting in development progress to a halt (if you fail to complete the task, you will have to work overtime)
  • 2 some friends are outsourcing companies, can not use the Internet (MMP Internet does not have, how can I Google programming?
  • 3. In case EasyMock loses your important information that day (it won’t be useful if you Sue him)

Start fast (the bus to kindergarten is leaving, get on and fasten your seat belt)

To begin, assume that you have successfully installed Node.js (>= v8.9) & MongoDB (>= v3.4) & Redis (>= v4.0).

Mongo installation tutorial: www.runoob.com/mongodb/mon…

Redis installation tutorial: www.runoob.com/redis/redis…

Tips tips

  • Node.js and mongodb are usually installed all the way to Next.
  • Redis download down is compressed package, decompress on the line

Check whether the installation is successful

  • Node.js will work with NPM, or output the Node version
  • Mongodb finds the installed folder (usually in the defaultC: \ Program Files \ mongo \ Server \ 4.0 \ binDouble-click mongo.exe, enter DB and press Enter to display test database

  • Redis check for success by looking at the installation tutorial above.

The installation

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

The configuration file

Find config/default.json, or create a config/local.json file and replace the following fields with your own configuration. (Configuration files do not need to be modified by default)

Different environments load different configuration files, so you should be familiar with Node-config before doing so.

{" port ": 7300, / / easymock port of project startup," the host ":" 0.0.0.0 ", "pageSize" : 30, "proxy" : false, "db" : "Mongodb ://localhost/easy-mock",// Instead of creating a new database, create a new interface on the startup easyMock. "unsplashClientId": "", "redis": {"port": 6379,// Redis port "host": "localhost"}, "blackList": {"projects": [], // projectId, example: "5A4495E16EF711102113E500" "IPS ": [] / / IP, example: "127.0.0.1"}, "rateLimit" : {" Max ": / / https://github.com/koajs/ratelimit 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/" } }Copy the code

Start the

$NPM run dev # Visit http://127.0.0.1:7300Copy the code

At this point we open a random interface preview, copy the URL and test the interface OK with Postman

For more requirements configuration, see the official website documentation for details, I will not go into more details.

Vue learning group 493671066, many beauties. Get in the old driver. There’s no time to explain.

Author related Vue articles

Background system permission control based on Vue2.0

Vue2.0 – Skin Based on ElementUI [Custom theme]

Front-end Document Summary

VUE2.0 add delete add edit add Model (popbox) component sharing

To express heartfelt thanks