Easy-mockhtml
easy-mock是一款比较好用的接口模拟工具,node
使用以前咱们须要安装和配置git
须要下载的内容有如下github
Node和Redis一路点下一步就行, MongoDB能够参考 MongoDB安装和运行redis
安装完成后就能够从github上下载easy-mock并开始使用了mongodb
$ git clone https://github.com/easy-mock/easy-mock.git $ cd easy-mock && npm install
依赖安装完成后能够开始修改配置文件npm
配置文件位于目录下的 config/default.json,或者建立一个 config/local.json 文件,将以下须要替换的字段换成本身的配置便可。json
官方配置模板 :bash
{ "port": 7300, "host": "0.0.0.0", "pageSize": 30, "proxy": false, "db": "mongodb://localhost/easy-mock", "unsplashClientId": "", "redis": { "keyPrefix": "[Easy Mock]", "port": 6379, "host": "localhost", "password": "", "db": 0 }, "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 } }, "ldap": { "server": "", // 设置 server 表明启用 LDAP 登陆。例:"ldap://localhost:389" 或 "ldaps://localhost:389"(使用 SSL) "bindDN": "", // 用户名,例:"cn=admin,dc=example,dc=com" "password": "", "filter": { "base": "", // 查询用户的路径,例:"dc=example,dc=com" "attributeName": "" // 查询字段,例:"mail" } }, "fe": { "copyright": "", "storageNamespace": "easy-mock_", "timeout": 25000, "publicPath": "/dist/" } }
若是不太懂 node-config 的话,你只须要知道开头的port和host,决定了你模拟接口运行的路径,其余直接用就好了。服务器
配置完成后,打开命令行,来到MongoDB根目录,运行Mongod服务器,而后就能够运行程序使用接口了。
$npm run dev
若是只是小项目的话也能够用 Charles 来模拟数据接口,具体的使用能够进入 Charles 官网阅读文档