giri-rest-api-proxy

1.0.0 • Public • Published

giri-rest-api-proxy

REST API proxy plugin of the giri system

npm version Build Status Coveralls

This plugin is a naiv implementation of a web proxy, that proxies each incoming HTTP request between the client and the seneca microservices.

It defines routes for all the endpoints defined by the giri-rest-api and converts them to synchronous internal microservice requests. The rule of conversion is that each incoming request is forwarded to an microservice that is listening for two properties in the pattern:

  • role: which is always has the value of giri-web, and
  • uri: which is the pattern defined in the service.yml endpoint descriptor as a uriTemplate property. Important to note that the { and } characters in the patterns are converted to :, because it seems that the jsonic library currently does not really like the } characher in patterns.

The targeted microservice also get the following parameters:

  • method: The HTTP method,
  • request: The whole request object of the incoming call,
  • endpoint: The endpoint descriptor, as and object, which is described in the corresponding service.yml under the giri-rest-api/lib folder.

The response of the microservice will be sent back as an HTTP response to the client.

This plugin uses the hapi server to handle the HTTP requests.

In fact these requests are handled by the giri-web plugin. There is also possible to directly map the incoming calls to microservices with seneca-web and simply configure the hapi as an adapter, which is probaly a simpler approach to solve the same problem.

Installation

Run the install command:

npm install

Run tests:

npm test

To obtain coverage:

run coverage

References


This project was generated from the seneca-plugin-archetype by the kickoff utility.

Readme

Keywords

none

Package Sidebar

Install

npm i giri-rest-api-proxy

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • tombenke