1、配置环境
缺一不可,重点是版本对应
Node.js (v8.x, v10.x is not supported) MongoDB (>= v3.4) Redis(>= v4.0) # mongod --version db version v3.4.20 # redis-cli --version redis-cli 3.0.2 # node -v v8.15.1
2、下载安装
$ git clone https://github.com/easy-mock/easy-mock.git $ cd easy-mock && npm install
配置文件说明
打开项目下的config/default.json文件,如无特别需要就不用改了
{ "port": 7300,//easymock项目启动的端口 "host": "0.0.0.0", "pageSize": 30, "proxy": false, "db": "mongodb://localhost/easy-mock",// 不需要自己新建数据库,在启动的easymock新建接口即可 "unsplashClientId": "", "redis": { "port": 6379,//redis端口 "host": "localhost" }, "blackList": { "projects": [], // projectId,例:"5a4495e16ef711102113e500" "ips": [] // ip,例:"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/" } }
3、运行
$ npm run build $ npm run start