Socket
Socket
Sign inDemoInstall

datahub-proxy-middleware

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datahub-proxy-middleware

datahub proxy middleware


Version published
Weekly downloads
1.6K
decreased by-10.87%
Maintainers
4
Weekly downloads
 
Created
Source

datahub-proxy-middleware

NPM version build status Test coverage npm download


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

live demo

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)

Keywords

FAQs

Package last updated on 16 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc