Giter Site home page Giter Site logo

mock-server's Introduction

moserver

本来用名mock-server发现被用了,果断改名moserver

这是一个local static server;其实一直用F5,mac下面启动啥的不太稳定,看官方建了好久的f5.js一直没写,然后结合现在想用的功能写了个;设置页面使用了vue,练手一下

  • 支持livereload
  • mock文件自动输出,模拟接口数据
  • 支持回调,这样方便数据处理
  • 反向代理(就这么叫吧。。),将接口映射到线上服务,调试代码更方便

使用

npm i -g moserver
ms 
# ms -h

访问配置页面

http://localhost:端口号/_/

mockjs支持

将mockjs格式的文件命名为.mock会自动编译

数据处理

要处理的文件同名放个xxx.ms,格式参考node module格式,实例如下:

module.exports = function (data, q, $) {
  //data是文件内容,q是query,$是cheerio 可以$.load(data)之后类似jquery方式处理页面数据
  var cb = q.callback;
  if (cb) {
    return cb + '(' + data + ')';
  }
  return data;
}

mock-server's People

Contributors

ksky521 avatar

Watchers

 avatar  avatar

Forkers

leamiko

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.