Regard
Sugar-interface to access multiple data sources.
Example
In the example below, we will:
- Create a new instance of Regard ;
- Load two connectors (FsConnector and HttpConnector) ;
- Create two major endpoints (
root
which give access to the current folder andmb
which give access to the Mockbin API); - Execute a request to http://mockbin.com/request, write the result into
sample.json
, read it and print the content on the standard output.
var Regard = ; // #1 Create a new instance of Regardvar regard = ; // #2 Load two connectorsregard ; // #3 Create two major endpointsregard ; // #4 Execute a request to http://mockbin.com/request ;
We can rewrite this example with less code lines:
- Create an instance of Regard initialized with FsConnector and HttpConnector ;
- Create two major endpoints and two nested endpoints (one under the
mb
endpoint and an other under theroot
endpoint); - Execute a request, write the result into
sample.json
and print it.
var Regard = ; // #1 Create an instance of Regard initialized with two connectorsvar regard = ; // #2 Create two major endpoints and one nested endpoint under each of themregard mb root; // #3 Execute a request, write and print the resultregardmb ;
The two example above have the same result: the request's response is wrote into sample.json
.
$ cat sample.json
Tests
npm test