Code Monkey home page Code Monkey logo

mock-server's People

Contributors

dependabot[bot] avatar funkylover avatar

Stargazers

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

Watchers

 avatar

mock-server's Issues

mock面板显示优化

勾选的set流程中的api, 在mock面板中有对应的api项, 此时要优化mock面板的显示提示用户因为会优先匹配中set面板中数据, 所以mock面板中的数据不会生效

Feature request: mock item加上复制url按钮及快速勾选

快速勾选

在api列表中每一项的前面都有checkbox,如果该api只有一个mock,可以快速切换,如果有多个mock,则只能反选

复制url

api列表中每一项都有两个复制按钮,一个是复制完整url,一个是复制验证url(/$mock-api?api=${api})

restful api 支持

问题

对于 restful api 来说, 如 /api/user/:id, mock需要支持以下各种情况

GET /api/user/:id

POST /api/user

PUT /api/user/:id

# ....

目前 mock-server 没有针对该场景做优化, 目前只能通过 data.js 导出 function, 并在其中判断 http method 后返回不同的数据

优化目标

初步设想如下

/api/user/:id
  - get.js
  - post.js
  - put.js
  - ....

当命中 /api/user/:id 后, 会再去判断对应的 http method, 执行不同的js文件

data.js一样, get/post/put等js文件可以直接导出一个数据对象, 也可以导出一个方法

当没有匹配的时候, 如 GET /api/user/123, 但是 /api/user/:id 目录下没有 get.js, 就返回 405 method not allowed

Feature Request: 内置常用代理模块

如需要调试服务端渲染页面, 其中代理的代码几乎重复的

考虑将其封装成一个代理方法/模块, 内置到mock-server中去

前后端分离之更好的mock你的后端api#模板接口调试 & 微信登录支持 中的例子

const proxy = require('mock/proxy');

proxy({
  url: 'https://api.target.com',
  ip: 'xxx.xx.xx.xxx', // 目标服务器ip, 如果不指定ip, 则转发到域名`api.target.com`对应的服务器
  pfx: fs.readFileSync('path/to/cert'),
  passphrase: 'password of cert'
}).then(res => {
  console.log(res); // 目标服务器的响应, 此时可以对其进行修改再返回至客户端
});

Feature request: mock path resolver

// mock/_set/流程1/api.target.com/api/login/data.js
const data = resolve('成功登陆'); // mock/api.target.com/api/成功登陆/data.js

module.export = data;

前端页面样式更新

目前前端页面和交互都过于粗糙

后续参考下市面上其他admin boilerplate的样式改造一下

SSR parser

内置后端模板引擎解析器?

  • ssi
  • clearsliver
  • 等等..

配置 POST 请求/RESTFul 风格 API 的示例

第一个问题:
关于 POST 的方式,文档没有看到相关说明,我试了 POST 对应的请求,结果是 404.

响应为:ENOENT: no such file or directory, stat .....

第二个问题:
#7 应用是支持了 Restful 风格的接口配置,希望补充下使用说明。

travis-ci error, "must be logged in to publish packages"

npm ERR! publish Failed PUT 401
npm ERR! code E401
npm ERR! You must be logged in to publish packages. : mock-server-local
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2019-03-21T12_31_02_715Z-debug.log

mock set交互调整

简单来说就是批量切换的功能

现在哪怕使用新增的resolver也不能解决这个问题

proxy特性默认关闭

目前proxy属性会默认打开,即没有命中mock的api会直接代理到线上或指定ip

后续该特性会默认关闭,需要在proxy.js指定打开

module.exports = {
  'api.target.com': true,
  'api.mock.com': ww.xxx.yy.zzz
};

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.