@makeflow/gateway
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.15 • Public • Published

    Makeflow Gateway

    A configurable gateway for development and production.

    Usage

    import {
      Gateway,
      createIndexFileFallbackMatchPathRegex,
    } from '@makeflow/gateway';
    
    // development
    
    const KOA_KEYS = ['dev'];
    
    const gateway = new Gateway({
      keys: KOA_KEYS,
      listen: {
        port: 8080,
      },
      session: {
        rolling: true,
      },
      targets: [
        {
          type: 'proxy',
          match: '/app/api',
          base: 'http://localhost:8081',
        },
        {
          type: 'proxy',
          match: '/app',
          base: 'http://localhost:8082',
        },
        {
          type: 'proxy',
          match: '/api',
          base: 'http://localhost:8061',
        },
        {
          type: 'proxy',
          match: '',
          base: 'http://localhost:8062',
        },
      ],
    });
    
    // production
    
    const KOA_KEYS = ['some secrets'];
    
    const gateway = new Gateway({
      keys: KOA_KEYS,
      listen: {
        port: 8080,
      },
      session: {
        rolling: true,
      },
      targets: [
        {
          type: 'proxy',
          match: '/app/api',
          base: 'http://makeflow-app-server:8081',
        },
        {
          type: 'file',
          match: createIndexFileFallbackMatchPathRegex('/app'),
          base: Path.join(__dirname, '../../static/app/index.html'),
        },
        {
          type: 'static',
          match: '/app/',
          base: Path.join(__dirname, '../../static/app'),
        },
        {
          type: 'proxy',
          match: '/api',
          base: 'http://makeflow-community-site-server:8061',
        },
        {
          type: 'file',
          match: createIndexFileFallbackMatchPathRegex(),
          base: Path.join(__dirname, '../../static/site/index.html'),
        },
        {
          type: 'static',
          match: '/',
          base: Path.join(__dirname, '../../static/site'),
        },
      ],
    });
    
    gateway.serve();

    License

    MIT License.

    Keywords

    none

    Install

    npm i @makeflow/gateway

    DownloadsWeekly Downloads

    77

    Version

    0.1.15

    License

    MIT

    Unpacked Size

    82.7 kB

    Total Files

    39

    Last publish

    Collaborators

    • vilic
    • maolion
    • hardo
    • dizy
    • boenfu
    • yggdrasilqh
    • pullup