Coder Social home page Coder Social logo

praveenmunagapati / pipa-gateway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from monologid/pipa-gateway

0.0 1.0 0.0 27 KB

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

License: Apache License 2.0

JavaScript 97.50% CSS 0.72% HTML 1.78%

pipa-gateway's Introduction

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

pipa-gateway's People

Contributors

septiyanandika avatar madebyais avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.