pengkobe / reading-notes

:stars: to record daily reading notes. I build an issue blog to record daily FE study notes. suggestion and comments are welcomed.
https://github.com/pengkobe/reading-notes/issues
MIT License
13 stars 1 forks source link

如何使用 mock server #47

Open pengkobe opened 7 years ago

pengkobe commented 7 years ago

做什么

方案

第三方可视化数据平台

RAP

node 搭建本地 mock server

使用 gulp 或者 webpack 插件

参考

这里,几位大神分享了自己的做法。

pengkobe commented 7 years ago

实例参考

var stubby = require('gulp-stubby-server'),
  path = require('path');

const options = {
  callback: function (server, options) {
    // console.log(server.endpoints.db);
  },
  stubs: 8000,
  tls: 8443,
  admin: 8010,
  quiet: false,
  relativeFilesPath: true,
  files: [
    path.join(__dirname, '../mocks/**/*.{yaml,js}')
  ]
};

stubby(options, function (error) {
  if (!error) {
    return console.log("Server start at: 'http://localhost:8000");
  }

  console.log("******Mock server get error******", error);
});

参考

https://github.com/greengerong/rebirth