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. Nodejs and Browser compatible!

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-87.5%
Maintainers
3
Weekly downloads
 
Created
Source

halfpenny // COINS API Javascript client

What is a halfpenny, anyway? Beyond an old-timey coin, 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

request

In order to keep the use of this client as flexible as possible, the client needs to be initialized with a function that can be used to make XHR requests. The client was designed to work with the request package, but it can be adapted to work with others (like browser-request, or xhr).

configuration

basic configuration:

const request = require('request');
const Promise = require('bluebird');
const apiClientOptions = {
    requestFn: Promise.promisify(request),
    baseUrl: 'http://localhost:3000'
};j
const client = require('../sdk/index.js')(apiClientOptions);

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

advanced configuration:

This client can use multiple request engines to make requests to the API. This allows the COINS team to use the client for its integration tests as well as for its browser application. Most of the configuration is centered around mapping the parameters that the client will feed to the request engine. If you are using request as your request engine, then there is no configuration needed. See nodeapi/test/utils/init-api-client for an example of how to configure the client to use hapi server.injectThen.

usage

Once you have a configured client, you can use the following methods to interact with the COINS API:

{Promise} = .auth.login(username, password)

Sends POST request to /auth/keys, and stores resulting credentials.

{Promise} = .auth.logout(username, password)

Sends DELETE request to /auth/keys, and removes credentials.

{Promise} = .getAuthCredentials()

Get the credentials currently stored.

{Promise} = .setAuthCredentials(val)

Set the credentials stored: will overwrite if already set.

{Promise} = .makeRequest(options, sign)

Takes a set of request options formatted for the request library, and modifies the options according to the requestObjectMap before signing the request (if sign !== false) and sending it.

Examples

See nodeapi/test/integration/keys.js

FAQs

Package last updated on 21 Jan 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