lib-gms-base
v0.0.1
Published
Base GMS libraries
Downloads
2
Readme
microservice-utility-vn-node
Install
npm install pizzahutuk/microservice-utility-vn-node
Components
Cors Middleware
Register in root file
const app = express();
const middlewareUtilityVnNode = require('microservice-utility-vn-node').Middleware;
app.use(middlewareUtilityVnNode.corsMiddleware.setCorsHeader());
Jwt Middleware
Register in router file
const router = require('express').Router();
const middlewareUtilityVnNode = require('microservice-utility-vn-node').Middleware;
const jwtAuth = middlewareUtilityVnNode.jwtAuthMiddleware;
router.route('/').get(jwtAuth.handle(), function (req, res) {
res.sendStatus(200);
});
If use with ClientFetcher middleware, you must place JwtAuth before ClientFetcher middleware.
const middlewareUtilityVnNode = require('microservice-utility-vn-node').Middleware;
const jwtAuth = middlewareUtilityVnNode.jwtAuthMiddleware;
const clientFetcher = middlewareUtilityVnNode.clientFetcherMiddleware;
router.route('/').get(jwtAuth.handle(), clientFetcher.handle(), function (req, res) {
res.sendStatus(200);
});
Define environment variable
JWT_SECRET={jwt-secret-key}
TENANT_BASE_URL={tenant-internal-domain}
REDIS_HOST={redis-host}
# Predefined env (optional)
INTERNAL_DOMAIN_PATTERN=/.*\.phdva.io$/
ClientFetcher Middleware
Register in router file
const router = require('express').Router();
const middlewareUtilityVnNode = require('microservice-utility-vn-node').Middleware;
const clientFetcher = middlewareUtilityVnNode.clientFetcherMiddleware;
router.route('/').get(clientFetcher.handle(), function (req, res) {
res.sendStatus(200);
});
Define environment variable
TENANT_BASE_URL={tenant-internal-domain}
REDIS_HOST={redis-host}