This package includes some utilities used by alpha-scripts
npm i --save-dev alpha-utils
yarn add --dev alpha-utils
Just add the middleware to your webpack
config as follows:
webpack.config.js
const mockMiddleware = require('alpha-utils/mockMiddleware');
module.exports = {
devServer: {
before(app) {
app.use(mockMiddleware({path: './mock'}))
}
}
}
You can also use the middleware in Express app. For example:
var express = require('express');
var mockMiddleware = require('alpha-utils/mockMiddleware');
var app = express();
...
app.use(mockMiddleware({path: './mock'}))
set the path where the mock files in
when set to true
, all mock routes are disabled