dxy-f2e / api-mocker Goto Github PK
View Code? Open in Web Editor NEWApi Mocker is more of an api management system than a mocker.
License: GNU General Public License v3.0
Api Mocker is more of an api management system than a mocker.
License: GNU General Public License v3.0
#大神,这个错遇到过么
2019-06-13 17:05:55,906 ERROR 30841 [master] agent_worker#1:30849 start fail, exiting with code:1
2019-06-13 17:05:55,906 ERROR 30841 [master] exit with code:1
{ Error: /usr/local/api-mocker-dev/server/node_modules/egg-bin/lib/start-cluster {"workers":1,"baseDir":"/usr/local/api-mocker-dev/server","framework":"/usr/local/api-mocker-dev/server/node_modules/egg"} exit with code 1
at ChildProcess.proc.once.code (/usr/local/api-mocker-dev/server/node_modules/common-bin/lib/helper.js:56:21)
at Object.onceWrapper (events.js:286:20)
at ChildProcess.emit (events.js:198:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) code: 1 }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: egg-bin dev
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-06-13T09_05_55_924Z-debug.log
生产环境中(make prod_server)发送的重置密码邮件中的链接,使用的是server/config/config.local.js中配置的clientRoot。
按照直觉,应该是server/config/config.prod.js
在接口文档tab下,由于api数量很多初次加载时,出现网页无法操作(卡死)。持续大约5分钟左右。
/home/app/api-mocker/server/node_modules/_egg-core@4.4.0@egg-core/lib/egg.js:239
const closeFunction = async () => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/home/app/api-mocker/server/node_modules/_egg-core@4.4.0@egg-core/index.js:3:17)
DEBUG=common-bin
for detail
提供订阅整个group的功能
1.group内新增、删除、修改接口可以得到提醒
接口列表界面 右边出来滚动条的时候 界面狂抖 根本停不下来
cd server
npm run dev报下面的错误
name: 'MongoError'
message: '[egg-mongoose]failed to connect to server [127.0.0.1:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]'
http://api-doc.ppvip.net/mock/#/login 本地部署后接口404 有没有交流群啊
Rap 更新了,数据结构不匹配,导入 Rap JSON 出现格式错误。简单修改了下(FromRap.vue),可以导入API 描述,但是参数和响应都没有:
moduleList = json.data.modules[0]
const apis = []
moduleList.interfaces.forEach(action => {
window.console.log(action)
const apiName = `${json.data.name}-${action.name}`
const api = new ApiInit()
api.name = apiName
api.desc = action.description
api.prodUrl = action.url
api.group = this.group._id
const requestType = Number(action.method)
api.options.method = this.methods[requestType - 1]
const requests = action.properties.filter(p => p.scope === 'request')
const responses = action.properties.filter(p => p.scope === 'response')
api.options.params = this.buildReqParams(api.options.params, requests, requestType)
api.options.response = this.buildResponse(responses)
apis.push(api)
})
整理一天就是不行
ajax GET 跨域请求到api-mocker地址,浏览器先发起了一个options,然后返回了跨域的响应头,状态码204,然后就没有发起GET请求了,什么原因呢?
这是我所能找到最适合我们需求的API管理工具
因为我们通过网络协作开发,所以该项目被我部署于公网上
但是目前而言,因为只要能访问到就可以随意注册带来了一些安全性问题
希望为每一个分组添加一个公参支持,可以支持 query, body, 以及 header 等
使用中遇到的问题:
1.api文档加载慢
2.文档在查看状态,再次编辑无法保存
3.希望可以进行多级分组管理用户和接口
应该不是浏览器的事儿
必须快速打字,或者每打一个字快速按回车才不会被删除。不知道是怎么回事儿
http://localhost:7001/auth/user/register 本地的这个请求失败 是因为没有不是什么东西吗?
众所周知
// example值为:
{
"status|1-2": true,
"number|1-100": 100
}
// 则会生成
{
"status": false,
"number": 40
}
那么如何生成一个随机时间?
是这样
{
"time|Random.time()": ""
}
还是
{
"time": Random.time()
}
上面两种方法都不行,生成的都是“Random.time()”字符串,期望得到的应该是一个随机时间,如"10:58:21"
Api Mokcer is more of an api management system than a mocker
2018-11-21 15:51:30,743 ERROR 6868 nodejs.AppWorkerDiedError: [master] app_worker#2:6889 died (code: 0, signal: null, suicide: false, state: dead), current workers: ["1","3","4"]
at Master.onAppExit (/www/wwwroot/server.api.xxx.com/server/node_modules/egg-cluster/lib/master.js:398:21)
at Master.emit (events.js:182:13)
at Messenger.sendToMaster (/www/wwwroot/server.api.xxx.com/server/node_modules/egg-cluster/lib/utils/messenger.js:133:17)
at Messenger.send (/www/wwwroot/server.api.xxx.com/server/node_modules/egg-cluster/lib/utils/messenger.js:98:12)
at EventEmitter.cluster.on (/www/wwwroot/server.api.xxx.com/server/node_modules/egg-cluster/lib/master.js:267:22)
at EventEmitter.emit (events.js:187:15)
at ChildProcess.worker.process.once (internal/cluster/master.js:193:13)
at Object.onceWrapper (events.js:273:13)
at ChildProcess.emit (events.js:182:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
name: "AppWorkerDiedError"
pid: 6868
hostname: VM_161_185_centos
2018-11-21 15:51:30,745 ERROR 6868 [master] app_worker#2:6889 start fail, exiting with code:1
2018-11-21 15:51:30,745 ERROR 6868 [master] exit with code:1
2018-11-21 15:51:30,752 ERROR 6877 [agent_worker] receive disconnect event on child_process fork mode, exiting with code:110
[root@VM_161_185_centos server]# node -v
v10.13.0
[root@VM_161_185_centos server]# npm -v
6.4.1
DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
问题描述
隔一段时间就会出现白屏一直加载的情况,查看network发现是一个vendor.js
请求时间超长,一直请求到分钟级别而后控制台报错net::ERR_CONNECTION_RESET 200
尝试过的措施
nginx
重启pm2
重启make install
重新启动mongodb
最后一步有效,但是该问题周期性出现,不知道根源在哪。
请问是否可以支持对系统的接口文档进行导出呢?
Schema已经编写保存,当再次更新时,只修改一个字段的类型,Schema to Example并不能更新Example中的字段类型,需要重新修改一下Schema中改字段的内容,即使内容一样。所以考虑更新字段的同时,保持Example同步更新。
mock 生成的url 是不确定,这个就导致我在开发的过程中不能和后端的api保持一致,
更倾向于 一个接口分组下的 生成的 mock 地址是可以 自己配置的:
group_basic_url/customize_url
这样就可以保证 之前代码的接口地址不做改动也能很好整合。
"dependencies": {
"blueimp-md5": "2.7.0",
"egg": "1.8.0",
"egg-cors": "1.0.0",
"egg-mongoose": "1.1.1",
"egg-redis": "1.0.1",
"egg-validate": "1.0.0",
"http-assert": "1.2.0",
"lru-cache": "4.1.1",
"mocker-dsl-core": "0.1.2",
"moment": "2.18.1",
"nodemailer": "4.0.1",
"path-to-regexp": "1.7.0",
"ramda": "0.23.0"
},
建议 egg 的依赖都改为 ^
的方式,我们会严格遵循 Semver 规则。
而且写死版本是没有用的,因为底层的依赖一样会用最新的。
Such as the "接口文档" page, the list data are always sorted by the last modify time. It is too hard to find the API document which I badly needed. Please provide this new feature and make it works in a new version, thank you very much!
Array[
Array []
]
假设api-mocker项目文件夹路径为__api_mocker_path
,网络域名为your-mocker.com
,
官方给的Nginx配置,需要访问http://your-mocker.com/mock
,一般情况下,为了方便,都是直接访问域名,可以修改Nginx配置如下:
1、
server {
listen 80;
server_name your-mocker.com;
root __api_mocker_path/client/dist;
index index.html;
location /mock-api/ {
proxy_pass http://127.0.0.1:7001/;
}
}
2、修改client/config/index.js
文件下的serverRoot,改为your-mocker.com/mock-api
3、访问your-mocker.com
希望予以采纳。
Request URL: http://f2e.dxy.net/mock-api/auth/user/register
Request Method: OPTIONS
Status Code: 500 Internal Privoxy Error
Remote Address: 127.0.0.1:1080
Referrer Policy: no-referrer-when-downgrade
c
其他功能点
· 接口测试。开发人员可以在系统上直接测试接口,避免在postman等请求工具上又填写众多参数
创建接口后,没有地方进行接口测试啊,怎么测试接口?
通过body中设置参数
{
"shartoken": 50067
}
测试dev模式,发现这个参数不能传递到api服务端,通过postman工具同样的参数是可以请求到数据的
使用安全模式启动MongoDB
(mongod --auth)后,修改server/config/config.default.js
中的mongoose
内容,原内容:
mongoose: {
url: 'mongodb://127.0.0.1/apimock'
}
修改后的内容:
mongoose: {
url: 'mongodb://apimock:[email protected]/apimock'
}
重新启动server,提示登录失败:undefined
,是不能使用安全模式启动MongoDB么?
develop版本备注和example写完就消失了
默认管理员账号是?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.