@quivers/node-driver
v2.0.10
Published
This is a node.js driver for preforming CRUD operations against the Quivers Cloudhub APIs. Requests are asynchronous, use gzip compression, and can support either 'application/json' or 'application/qhal+json' content types.
Downloads
5
Maintainers
Readme
Quivers Node Driver
This is a node.js driver for preforming CRUD operations against the Quivers Cloudhub & GraphHub APIs. This will eventually be paired with a node.js SDK, which will expose the domain model of the Quivers API in an easy to use package (which uses either the node.js or client javascript driver for core functionality).
How to Use
This driver is available as an NPM package.
npm install @quivers/node-driver
Once installed, it can be included in your application and used. By default, it will connect to the Live environment, with no context and no authentication.
var QuiversDriver = require("@quivers/node-driver");
var quivers = new QuiversDriver;
It can be initialized with a few different options as well.
var quivers = new QuiversDriver({
environment:"test",
business: "Business.RefId",
marketplace: "Marketplace.Id",
apikey: "User.ApiKey",
accept: "application/qhal+json" || "application/json",
gzip: true
});
You can also authenticate without an apikey by using Username/Password.
var quivers = new QuiversDriver;
quivers.auth("username", "password", function (err, boolWasSuccessful) { ... });
For a comprehensive explanation on how this library works, examine "examples.js". If making adjustments to this package, run "node test.js" to ensure everything works before pushing changes. An error will be thrown if something is not working correctly.
Available Functions
//HTTP GET request
quivers.get(endpoint, queryParams, callback(err, data){ ... })
//HTTP GET request, if the resource endpoint supports paging, it will fetch the all the requested data a page at a time and invoke the callback once it has all data.
quivers.pagedGet(endpoint, callback(err, data){ ... })
//HTTP POST request.
quivers.post(endpoint, data, callback(err, data){ ... })
//Authenticates as a Quivers User. Future requests will be made as an authenticated user, if it was successful.
quivers.auth(username, password, callback(err, boolWasSuccessful){ ... })
//Unauthenticates. This method will remove any authentication tokens/apikeys currently in use.
quivers.unauth(callback(err, boolWasSuccessful){ ... })
//Batch operations, allows one to specify multiple requests to make. It will perform them concurrently, and invoke the callback once all operations are complete.
quivers.batch([
{type: "get", uri: "Resource/Method", queryParams},
{type: "post", uri: "Resource/Method", data}
], callback(status, data) { ... })
Supported Features
- Concurrency; the library allows for requests to be made asynchronously, with a max of 2 concurrent requests across all instances of the Quivers object at any time (to prevent issues where too many concurrent requests slow things down or fail).
- Gzip Compression: Accepts gzip compressed responses from the API, and any data sent to the API will also be gzipped to minimize network bandwidth usage.
- Supports either 'application/qhal+json' (e.g. "userInfo.firstName") or 'application/json' (e.g. "UserInfo.FirstName") return types.
- Authentication via ApiKey or Bearer Tokens
- Business RefId context, when creating an instance of "QuiversDriver", you can specify a Business RefId to be used for all requests on that object.
- Marketplace Id context, when creating an instance of "QuiversDriver", you can specify a Marketplace Id to be used for all requests on that object.
- You can connect to all environments (internal, live, demo, test), and can run requests to different environments concurrently.
- Batch Operations, you can specify an unlimited number of batch operations to be completed, of both GET and POST types. Once all operations are completed, a callback is triggered with details about how all the batch operations completed.
Author
- Justin Frenzel (Senior Software Engineer @ Quivers)
- [email protected]
- [email protected]