vhttp
Promise based HTTP/HTTPS client with optional virtualization. Depends on request-promise. This is helpful for services / apis that call other services / apis, but want to allow for virtualizing (stubbing) those calls in tests, CI/CD pipeline, or volume / performance testing.
Installation
Install via npm as follows:
$ npm install vhttp --save
Usage
The most common usage is to pass a query or post param to your api indicating virtualization similar to:
http://hello.world.api/sayhello?virtual=notification
This could then be used in the service as follows:
var Promise = Vhttp = ; Vhttp
For more details on bluebird's Promise.all, check this out.
Then in a folder called virtual the following files would be created:
project\
virtual\
slack1.request.json // contains: { "message": "Hello World!" }
slack1.response.json // contains: { "status": "ok" }
hipchat1.request.json // contains: { "message": "Hello Workd!" }
hipchat1.response.json // contains: { "status": "ok" }
Now when we call
http://hello.world.api/sayhello?virtual=notification
the response is
For real (not virtualized) api calls just remove the virtual param
http://hello.world.api/sayhello