0.0.8 • Published 6 years ago

y-server-plugin-mock v0.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

y-server-plugin-mock

y-server-plugin-mock is a y-server plugin to mock data.

Install

npm install y-server-plugin-mock

Usage

const path = require('path');

const yServer = require('y-server');
const mockPlugin = require('y-server-plugin-mock');

yServer({
  plugins: [
    mockPlugin({
      mockEnable: true,
      mockDir: path.join(__dirname, './json'), // 模拟数据根目录
      mockAdapter: require('./json/adapter.js'),
      mockPaths: ['/api/*'],
    }),
    (app) => {
      app.get('/', (req, res, next) => {
        res.getMockData('/api/foo').then(data => res.send(data)).catch(next);
      });
    },
  ],
});

Notes

  • mockDir is the base directory of mock data.
  • mockAdapter is the adapter of mock data.

License

MIT License

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago