Package Exports
- @adedayomatthews/proxy-manager
- @adedayomatthews/proxy-manager/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@adedayomatthews/proxy-manager) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
This package is usable with express application to configure and manage endpoints for a configurable gateway. It also autogenerate a Swagger documentation.
Install
npm i @adedayomatthews/proxy-managerUsage
The package uses Sequelize ORM. Create a sequelize.js in your root folder of your project and configure the database connection there as:
module.export = {
"username": "root",
"password": "root",
"database": "database_name",
"host": "127.0.0.1",
"dialect": "mysql"
}Setup an express application
const express = require('express');
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));Initialize the proxy manager with the express app
const { ProxyManager} = require("@adedayomatthews/proxy-manager");
const proxyManager = new ProxyManager(app)Add the router for managing endpoints
app.use('/', proxyManager.getManagementRouter())Include Swagger documentation
proxyManager.addDocumentation()Include script in package.json
"proxy-sync": "cd ./node_modules/@adedayomatthews/proxy-manager && npm run sequelize-sync"You can now run npm run proxy-sync to sync the sequelize models.
You can also hook into Pre & Post Scripts to ensure the proxy is always synced. If you have a start script, you can add a prestart script, for example:
"start": "node app.js",
"prestart": "npm run proxy-sync",
"proxy-sync": "cd ./node_modules/@adedayomatthews/proxy-manager && npm run sequelize-sync"