Skip to content

Pipa Gateway is a module to help you create an API Gateway or Orchestrator in an easy way.

License

Notifications You must be signed in to change notification settings

SeptiyanAndika/pipa-gateway

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PIPA GATEWAY codecov

A NodeJS module to help you create an API Gateway in an easy way.

Why PIPA GATEWAY

The concept of PIPA GATEWAY is similar to PipaJS, to enable developer to create an orchestrator or an API Gateway or a proxy in easy way.

Installation

$ npm install pipa-gateway

var express = require('express')
var app = express()
var PipaGateway = require('pipa-gateway');

// PipaGateway
// @param   object      Express app
// @param   string      File json config
// @param   string      Middleware folder

var pipaGateway = new PipaGateway(app, { configPath: 'config.json', middlewarePath: 'middleware' });
pipaGateway.open();

app.listen(9000);

How-To

There are 3 features in pipa gateway, proxy, parallel and chain.

PROXY

Proxy will forward your request to services.

{
   "GET /users": {
    "type": "proxy",
    "service":
      {
        "name": "users",
        "url": "https://jsonplaceholder.typicode.com/users"
      }
  },
  "GET /user/:id": {
    "type": "proxy",
    "middlewares":["Auth.ensureAuth"],
    "service":
      {
        "name": "user",
        "url": "https://jsonplaceholder.typicode.com/users/:id"
      }
  }
}

PARALLEL

Parallel will request parallel to multilple services.

{
    "GET /parallel": {
        "type": "parallel",
        "services": [
          {
            "name": "user",
            "url": "https://jsonplaceholder.typicode.com/users"
          },
          {
            "name": "post",
            "url": "https://jsonplaceholder.typicode.com/posts"
          }
        ]
    }
}

Chain

Chain will request chain to multiple services, the next request will process after previous request successfully and can set parameter to the next request based on result on previous request.

{
   "GET /chain/:id": {
    "type": "chain",
    "services": [
      {
        "name": "user",
        "url": "https://jsonplaceholder.typicode.com/users/:id"
      },
      {
        "name": "post",
        "url": "https://jsonplaceholder.typicode.com/posts?userId={user.id}",
        "body":{
          "userId":"{user.id}"
        }
      }
    ]
  }
}

Code Example

You can try to run the code example in example folder.

License

Apache-2.0

Contributors

Faris

Septiyan Andika

About

Pipa Gateway is a module to help you create an API Gateway or Orchestrator in an easy way.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.5%
  • HTML 1.8%
  • CSS 0.7%