Douglas Lab API wrapper
This module provides a JavaScript wrapper for the Douglas Lab Inventory Management API.
Building the wrapper
$ git clone https://github.com/douglaslab/lab-api-wrapper.git$ cd lab-api-wrapper$ npm i$ npm run build
Wrapper classes
Currently (version 1.0.0) the wrapper provides 3 classes:
Items
- inventory management.Users
- users management.Admin
- log, permissions, and general operations.
Each class accepts 2 parameters at instantiation:
apiUrl
- points to the root of the server serving the URL.version
- the version of the API we're targeting. Defaults to latest.
The parameters allow us to use different versions and instances of the API with different classes, although that won't be needed until several versions of the API exist.
Sample usage
- Create an empty folder.
- Add a
package.json
file by runningnpm init
in the folder and answering the questions. - Add the wrapper module:
$ npm i --save lab-api-wrapper$ npm i --save async #see comment below
- Create a file called
index.js
:
;;const API_URL = 'https://bionano-api.herokuapp.com';const VERSION = '1.0.0';var items = API_URL VERSION;var users = API_URL VERSION; var myUser;var myItem; async;
- Run
node index.js
PS: the sample code makes use of the async
module, to synchronize the various calls - but you can use any alternative (such as promises, Q, generators, etc.).
Tests
Before running tests, add a file called params.json
to the tests folder:
Then run:
$ npm test