This article focuses on how to build easy-mock locally

1 Preconditions

First you need to install the environment required by Easy-Mock and Google it yourself

Node.js (v8.x, not v10.x) MongoDB (>= v3.4)Copy the code

2 Pull the easy-mock source code and install it

Execute the following code:


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

Copy the code

3 Modify the configuration file

Find the config/default. Json


{
  "port": 7300,
  "host": "0.0.0.0"."pageSize": 30."proxy": false."db": "mongodb://admin:123456@localhost:27017/easymockdb? authSource=admin"// mongodb:// username: password @mongodb address :mongodb port/project library name? authSource=admin"unsplashClientId": ""."redis": {
    "keyPrefix": "[Easy Mock]"."port": 6379, // Redis port number"host": "localhost"// Redis address"password": ""."db": 0}."blackList": {
    "projects": [], // projectId, for example:"5a4495e16ef711102113e500"
    "ips": [] // IP, for 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}},"ldap": {
    "server": ""// Set server to enable LDAP login. Ex. :"ldap://localhost:389""ldaps://localhost:389"(Using SSL)"bindDN": ""// User name, for example:"cn=admin,dc=example,dc=com"
    "password": ""."filter": {
      "base": ""// Query the user path, for example:"dc=example,dc=com"
      "attributeName": ""// Query fields, for example:"mail"}},"fe": {
    "copyright": ""."storageNamespace": "easy-mock_"."timeout": 25000,
    "publicPath": "/dist/"}}Copy the code

4 start

Execute the following code:


npm run dev

Copy the code

5 deployment

Execute the following code:

NPM run build pm2 start app.js // Install the PM2 daemon process. For details about how to use pM2, see the PM2 user manualCopy the code

Pm2 tutorial: Please Google

Author: Wang Shihong, Large front end R&D Center – Client R&D group

Recruitment information

Free big front end R&D center recruiting new students!

FE/iOS/Android engineer

Company benefits include:

  • Five insurances and one housing fund in full, plus commercial insurance
  • Free gym + annual physical examination
  • 10 percent discount for rent near the company
  • 2 promotions per year

Welcome to join us if you have passion for technology! Please send your resume to [email protected], or add wechat V-nice-V for details!