This is the node-express-gateway package which provides a small and easy API gateway. If you need more power and are looking for the express-gateway package click here: https://github.com/expressgateway/express-gateway
- Everything should be controllable through a YAML configuration file.
- The Gateway could be used programmatically or as CLI program
- The developer should be able to use which API framework should be used (express.js, fastify, restify, ...)
- It should be possible to build aggregates of routes
- Only TypeScript code
- Small dependency footprint
- Only use well known dependencies
Move to object oriented programming styleUse dependency injection patternUse inverson of control container (like inversify.js)
- Provide as executable
- Allow multiple API frameworks (for now express is hard-coded)
$ npm i node-express-gateway
$ # or
$ yarn add node-express-gateway
import Gateway from "../index";
const gw1 = Gateway();
const gw2 = Gateway();
gw1.run("./__tests__/fixtures/config.yml");
gw2.run("./__tests__/fixtures/config_2.yml");
port: 4000
authentication:
host: localhost
port: 3002
path: /api/user/auth/
routes:
- downstreamPath: /api/secret
downstreamHost: your-host.com
downstreamPort: 443
downstreamSSL: true
downstreamUrlSuffix: add-your-suffix-here-(is-added-to-url)
upstreamPath: /api/
upstreamMethods:
- get
auth: true
scopes:
- admin
- registered
- downstreamPath: /api/open
downstreamHost: your-host.com
downstreamPort: 443
downstreamSSL: true
downstreamUrlSuffix: add-your-suffix-here-(is-added-to-url)
upstreamPath: /api/open
upstreamMethods:
- get
auth: false