5.0.3 • Published 2 years ago
datahub-proxy-middleware v5.0.3
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)
5.0.3
2 years ago
5.0.2
3 years ago
5.0.1
3 years ago
5.0.0
4 years ago
4.0.0
4 years ago
3.1.1
4 years ago
3.1.0
4 years ago
3.0.1
4 years ago
3.0.0
4 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago