Nantes Paradox Market

    datahub-proxy-middleware

    5.0.3 • Public • Published

    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)

    Install

    npm i datahub-proxy-middleware

    DownloadsWeekly Downloads

    366

    Version

    5.0.3

    License

    MIT

    Unpacked Size

    9.51 kB

    Total Files

    4

    Last publish

    Collaborators

    • zyhack
    • xudafeng
    • zivyangll
    • chun_chan
    • snapre