Git Product home page Git Product logo

api-mocker's People

Contributors

atian25 avatar dependabot[bot] avatar foxpsd avatar guchongxi avatar lndj avatar lusq010 avatar wangqiang0121 avatar wuomzfx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-mocker's Issues

server工程启动不了?npm ERR! [email protected] dev: `egg-bin dev`

#大神,这个错遇到过么
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

cd server && cnpm install && npm run dev

/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)
⚠️ Error: /home/app/api-mocker/server/node_modules/_egg-bin@4.3.7@egg-bin/lib/start-cluster {"baseDir":"/home/app/api-mocker/server","framework":"/home/app/api-mocker/server/node_modules/egg","workers":1} exit with code 1
⚠️ Command Error, enable DEBUG=common-bin for detail

按group订阅功能

提供订阅整个group的功能
1.group内新增、删除、修改接口可以得到提醒

mongo导致启动失败

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]'

导入 RapJSON 提示格式错误

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)
      })

希望支持超级管理员用户以及可选关闭注册

这是我所能找到最适合我们需求的API管理工具
因为我们通过网络协作开发,所以该项目被我部署于公网上
但是目前而言,因为只要能访问到就可以随意注册带来了一些安全性问题

接口列表、接口文档中组的排序优化问题

前提是这样的:进入系统后,经常需要进行搜索或者下拉列表才能找到自己想编辑的组
image
请问是否可以增加一个支持:比如对自己曾经更改过组内接口的组、自己关系的组(订阅功能)进行一个置顶,便于查找。

请求 Body 不能是数组吗?

可以理解 form 数据是 key-value 存储的;

但是 json 数据的话,是支持整个数据为一个 array 的;
例如:
jietu20171010-201131

mock如何生成一个随机时间,或随机的中文等?

众所周知
// example值为:
{
"status|1-2": true,
"number|1-100": 100
}
// 则会生成
{
"status": false,
"number": 40
}
那么如何生成一个随机时间?
是这样
{
"time|Random.time()": ""
}
还是
{
"time": Random.time()
}
上面两种方法都不行,生成的都是“Random.time()”字符串,期望得到的应该是一个随机时间,如"10:58:21"

cd server && cnpm install && npm run dev

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

资源请求失败

问题描述
隔一段时间就会出现白屏一直加载的情况,查看network发现是一个vendor.js请求时间超长,一直请求到分钟级别而后控制台报错net::ERR_CONNECTION_RESET 200

尝试过的措施

  • 服务端nginx重启
  • 服务端pm2重启
  • 服务端项目根目录make install重新启动mongodb

最后一步有效,但是该问题周期性出现,不知道根源在哪。

增加状态码 405

default
这个可以优化一下
后端这边一般是用 405 (405 Method Not Allowed)
default
可以更加直观了解问题在哪里出现的。

Respone Schema 类型同步问题

Schema已经编写保存,当再次更新时,只修改一个字段的类型,Schema to Example并不能更新Example中的字段类型,需要重新修改一下Schema中改字段的内容,即使内容一样。所以考虑更新字段的同时,保持Example同步更新。

关于 Mock 生成的 Url

感谢作者提供这么好的工具,有个问题想请教下:

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 规则。
而且写死版本是没有用的,因为底层的依赖一样会用最新的。

May the Api-Mocker list data could be sorted by name?

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!

请求mocker时,一直返回验证不通过

image

如上图api接口的定义

通过postman打接口,如下图一直返回参数校验失败
image

最奇怪的是,如果把接口定义的必选都去掉,就正常了!

不知道问题出在哪,烦请指教。

优化Nginx配置

假设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

希望予以采纳。

如何进行接口测试

其他功能点
· 接口测试。开发人员可以在系统上直接测试接口,避免在postman等请求工具上又填写众多参数

创建接口后,没有地方进行接口测试啊,怎么测试接口?

Post 传值失败

通过body中设置参数
{
"shartoken": 50067
}
测试dev模式,发现这个参数不能传递到api服务端,通过postman工具同样的参数是可以请求到数据的

mongod安全模式问题

使用安全模式启动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么?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.