node
redis
mongodb
访问
easy-mock
下载
git clone https://github.com/easy-mock/easy-mock.git
执行
yarn
配置文件
找到 config/default.json,或者创建一个 config/local.json 文件,将如下需要替换的字段换成自己的配置即可
{
"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/"
}
}
启动
yarn dev

访问
http://localhost:7300
创建项目
https://petstore.swagger.io/v2/swagger.json
服务器部署
PM2
当在内网服务器部署时,推荐使用 PM2 来守护你的应用进程。
打包静态资源
yarn build
全局安装pm2
yarn global add pm2
启动easy mock
NODE_ENV=production pm2 start app.js