Skip to content

A Microservices API Gateway Built Using Express.js and Express Middleware.

Notifications You must be signed in to change notification settings

deevanshu-k/custom_gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Micro_Gateway-removebg-preview

INPORTANT NOTICE A Microservices API Gateway Built Using Express.js and Express Middleware. Micro gateway is a simple customizable gateway server.

Configuration

  1. add .env int root folder
  2. add PORT variable PORT=8080
  3. add proxy routes object in ROUTES Array in config/routes.js
     # Example object array
     let Routes = [{
         url: '/todos',
         authServices: [auth.checkForAuth,auth.checkForAuth2],
         creditCheck: false,
         proxy: {
             target: "https://jsonplaceholder.typicode.com",
             changeOrigin: true,
             pathRewrite: {
                 [`^/free`]: '',
             },
         }
     }]

Route Object

  1. options.url : Incomming route, we can use all express wildcard syntx in it.
  2. authServices : Array of valid middleware function
     function middleware(req,res,next){
         next();
     }
  3. creditCheck : Bool Value ( InDevelopment )
  4. proxy : Object
    • target : target url https://jsonplaceholder.typicode.com
    • changeOrigin : bool value for cors origin policy
    • pathRewrite : to rewrite the url path
      // host/free -> proxyhost/api
      pathRewrite: {
              [`^/free`]: '/api',
          }
    • we can add multiple rewrite rules
    // Example object array
    {
        url: '/todos',
        authServices: [auth.checkForAuth,auth.checkForAuth2],
        creditCheck: false,
        proxy: {
            target: "https://jsonplaceholder.typicode.com",
            changeOrigin: true,
            pathRewrite: {
                [`^/free`]: '',
            },
        }
    }

About

A Microservices API Gateway Built Using Express.js and Express Middleware.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published