halfpenny
![Coverage Status](https://coveralls.io/repos/github/MRN-Code/halfpenny/badge.svg?branch=master)
The official COINS API Javascript client
What is a halfpenny, anyway? Beyond an old-timey coin (AKA a pence), halfpenny is the official javascript API client for the COINS platform. halfpenny works in the browser and in nodejs.
usage
const hp = require('halfpenny')
const client = hp.factory({}, (err, client) => {
client.auth.login('username', 'pw')
.then(resp => console.log(resp.data.data[0].user))
.catch(err => console.error(err));
});
halfpenny is written in nodejs-style commonjs. Therefore, if you are using it in the browser, make sure you are bundling it with browserify/webpack/etc! We do provide a bundled version on your behalf. See dist/
.
peer dependencies
storage
In order to persist data to disk, a localStorage
interface is required. In the
browser, this will default to window.localStorage
. If you use nodejs, you must pass in a localStorage
-like interface, such as node-localstorage
or dom-storage
.
how it works
The source code for the client is auto-generated during the build process of the
API itself. The API then bundles and serves the source code from /client/client.js
.
This package retrieves the bundled source code and evaluates it. The result is an
object with properties corresponding to each method exposed by an API endpoint
(e.g. ScansApi.get()
).
See nodeapi/test/integration
for more
todo
- Auto-generate documentation from API client
changelog
- 3.x
- add build, address env incompatibility
- 2.x
- convert to auto-generated api client, built from server API spec
- remove browser support temporarily
- 1.x
- 0.x