Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

halfpenny

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

halfpenny

Official javascript COINS API client. Not browser compatible!

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
3
Weekly downloads
 
Created
Source

halfpenny // 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.

alpha warning

halfpenny is still in active development! it is not ready for public usage!

peer dependencies

axios

A HTTP request agent is required to retrieve the Client source code and to make requests. Axios was chosen as that client in order to support both server and browser environments.

storage

In order to persist data to disk, a localstorage interface is required. In the browser, this means supplying window.localStorage in the browser, and using node-localstorage or dom-storage on the server.

basic configuration

See examples The above configuration parameters are required. Note that the 'requestFn' must be promisified

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()).

examples

const agent = require('axios');
const DomStorage = require('dom-storage');
const store = new DomStorage('/path/to/file', {strict: true});
const apiClientOptions = {
    xhrAgent: agent,
    baseUrl: 'http://localhost:8800', // hostname:port of nodeapi service
    store: store
};
const clientReady = require('halfpenny')(apiClientOptions)
    .catch((err) => {
        //whoops
    });

// login
clientReady.then((client) => {
    return client.auth.login('username', 'password');
});

// get scans
clientReady.then((client) => {
    return client.ScansApi.get(null, 'M87100000')
});

See nodeapi/test/integration for more

todo

  • support UMD and browser compatibility.
  • Auto-generate documentation from API client

changelog

  • 2.x
    • convert to auto-generated api client, built from server API spec
    • remove browser support temporarily
  • 1.x
    • commonjs-ify
  • 0.x
    • init

FAQs

Package last updated on 03 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc