sylph-plugin-remote-gateways
v1.6.0
Published
A plugin for Sylph allowing remote gateways for micro-services
Downloads
2
Readme
Sylph Plugin: Remote Gateways
Remote gateways are a way to interface multiple APIs in a developer-friendly way.
Usage:
- Create a
gateways.json
file in the process root directory - Add Gateway Endpoint:
{
"auth": {
"endpoints": {
"production": {
"address": "https://api.example.com",
"key": "test-key"
}
}
}
}
- Add gateway middleware to Sylph Project:
const sylph = require('sylph-server');
const { injectGateways } = require('sylph-plugin-remote-gateways');
sylph.expand([
injectGateways()
]);
- 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);
};