sylph-plugin-remote-gateways

1.6.0 • Public • Published

Sylph Plugin: Remote Gateways

Remote gateways are a way to interface multiple APIs in a developer-friendly way.

Usage:

  1. Create a gateways.json file in the process root directory
  2. Add Gateway Endpoint:
{
  "auth": {
    "endpoints": {
      "production": {
        "address": "https://api.example.com",
        "key": "test-key"
      }
    }
  }
}
  1. Add gateway middleware to Sylph Project:
const sylph = require('sylph-server');
const { injectGateways } = require('sylph-plugin-remote-gateways');

sylph.expand([
  injectGateways()
]);
  1. Access a gateway using req.gateways..post(, {})
module.exports.handler = async (req, res) => {
  const {username, password} = req.body;
  const result = req.gateways['auth'].post('login',{username, password})
  return res.status(200).send(result);
};

Readme

Keywords

none

Package Sidebar

Install

npm i sylph-plugin-remote-gateways

Weekly Downloads

0

Version

1.6.0

License

Apache-2.0

Unpacked Size

4.5 kB

Total Files

7

Last publish

Collaborators

  • jetdevuk