Skip to content

A configurable gateway for development and production.

License

Notifications You must be signed in to change notification settings

mufancom/gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 14, 2023
5a9b312 · Nov 14, 2023

History

56 Commits
Nov 14, 2023
Nov 14, 2023
Nov 14, 2023
Nov 14, 2023
Jul 12, 2020
Nov 14, 2023
Nov 14, 2023
Mar 20, 2023
Nov 14, 2023
Sep 28, 2021
Mar 20, 2023
Nov 14, 2023
Nov 14, 2023
Nov 14, 2023
Nov 14, 2023
Sep 28, 2021
Nov 14, 2023

Repository files navigation

NPM version Repository package.json version MIT License Discord

Makeflow Gateway

A configurable gateway for development and production.

Usage

import {
  Gateway,
  createIndexFileFallbackMatchPathRegex,
} from '@makeflow/gateway';

// development

const gateway = new Gateway({
  listen: {
    port: 8080,
  },
  targets: [
    {
      type: 'proxy',
      match: '/app/api',
      target: 'http://localhost:8081{path}',
    },
    {
      type: 'proxy',
      match: '/app',
      target: 'http://localhost:8082{path}',
    },
    {
      type: 'proxy',
      match: '/api',
      target: 'http://localhost:8061{path}',
    },
    {
      type: 'proxy',
      match: '',
      target: 'http://localhost:8062{path}',
    },
  ],
});

// production

const gateway = new Gateway({
  listen: {
    port: 8080,
  },
  targets: [
    {
      type: 'proxy',
      match: '/app/api',
      target: 'http://makeflow-app-server:8081{path}',
    },
    {
      type: 'file',
      match: createIndexFileFallbackMatchPathRegex('/app'),
      target: Path.join(__dirname, '../../static/app/index.html'),
    },
    {
      type: 'file',
      match: '/app',
      target: Path.join(__dirname, '../../static/app{path}'),
    },
    {
      type: 'proxy',
      match: '/api',
      target: 'http://makeflow-community-site-server:8061{path}',
    },
    {
      type: 'file',
      match: createIndexFileFallbackMatchPathRegex(),
      target: Path.join(__dirname, '../../static/site/index.html'),
    },
    {
      type: 'file',
      match: '',
      target: Path.join(__dirname, '../../static/site{path}'),
    },
  ],
});

gateway.serve();

License

MIT License.