Git Product home page Git Product logo

hew's Introduction

Hew

Hew provides a Node.js API for HP Cloud.

API Documentation

Hew API Documentation is at: http://natesilva.github.io/hew/docs/#!/api

Github

The Hew Github repository is at: https://github.com/natesilva/hew

Coverage

Currently Hew supports a subset of the HP Cloud API:

  • Authentication Tokens
  • Messaging
  • DNS
  • Object Storage
  • CDN (partial)
  • Identity (partial)

Installation

npm install hew

Quick start

Example showing use of the Messaging module:

var Hew = require('hew');

var yourRegion = Hew.AuthToken.DEFAULT_REGION;
var yourAccessKey = '…';
var yourSecretKey = '…';
var yourTenantName = '…';
var qname = 'my-test-message-queue';

// obtain an authentication token
var token = new Hew.AuthToken(yourRegion, yourAccessKey, yourSecretKey,
  yourTenantName);

// create the Messaging controller
var messaging = new Hew.Messaging(token);

// create a test queue
messaging.createQueue(qname, function(err) {
  if (err) { return console.error(err); }
  console.log('test queue created');

  // send a message
  var message = { location: 'Palo Alto', temperature: 22, units: 'C' };
  messaging.send(qname, message, function(err, messageId) {
    if (err) { return console.error(err); }
    console.log('message was posted, with ID', messageId);

    // receive a message
    messaging.receive(qname, function(err, message) {
      if (err) { return console.error(err); }
      console.log('message received:', message.body);
      // prints: { location: 'Palo Alto', temperature: 22, units: 'C' }

      // delete the test queue
      messaging.deleteQueue(qname, function(err) {
        if (err) { return console.error(err); }
        console.log('test queue deleted');
      });
    });
  });
});

Running unit tests

Warning: Do not run unit tests against your production HP Cloud account. Testing will create, update and delete resources in your account, including very large files for testing object storage.

To run unit tests:

  1. Check out the Hew git repo.
  2. Create tests/config.json (an example is provided).
  3. Add the following key to tests/config.json:
    • "i-created-this-account-for-testing-only": true
  4. From the the top of the repo, run npm install.
  5. From the the top of the repo, run npm test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.