giri-rest-api-proxy
v1.0.0
Published
REST API proxy plugin of the giri system
Downloads
2
Readme
giri-rest-api-proxy
REST API proxy plugin of the giri system
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 ofgiri-web
, anduri
: which is the pattern defined in theservice.yml
endpoint descriptor as auriTemplate
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 wholerequest
object of the incoming call,endpoint
: The endpoint descriptor, as and object, which is described in the correspondingservice.yml
under thegiri-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.