datahub-proxy-middleware
v5.0.3
Published
datahub proxy middleware
Downloads
7,733
Readme
datahub-proxy-middleware
datahub proxy middleware
Contributors
|xudafeng|zivyangll|Chan-Chun|zhangyuheng|zhuyali| | :---: | :---: | :---: | :---: | :---: |
This project follows the git-contributor spec, auto updated at Thu Mar 18 2021 13:45:58 GMT+0800
.
Installment
$ npm i datahub-proxy-middleware --save-dev
Common Usage
const datahubMiddleware = require('datahub-proxy-middleware');
const datahubConfig = {
proxy: {
'/api': {
hub: 'project_name',
port: 8080,
hostname: 'localhost',
pathOptions: {
start: true
}
},
},
};
datahubMiddleware(app)(datahubConfig);
notice version 6 has a break change that needs special attention, see more details.
Use with webpack-dev-server
const path = require('path');
const DataHub = require('macaca-datahub');
const datahubMiddleware = require('datahub-proxy-middleware');
// datahub config
// document: https://github.com/macacajs/macaca-datahub#configuration
const datahubConfig = {
port: 5678,
hostname: '127.0.0.1',
pathOptions: {
start: true,
end: false
},
store: path.join(__dirname, '..', 'data'),
proxy: {
'/api': {
hub: 'sample',
},
},
showBoard: true,
};
const defaultDatahub = new DataHub({
port: datahubConfig.port,
});
// devServer field
devServer: {
before: app => {
datahubMiddleware(app)(datahubConfig);
},
after: () => {
defaultDatahub.startServer(datahubConfig).then(() => {
console.log('datahub ready');
});
},
},
showBoard will inject debugger-board
License
The MIT License (MIT)