0.0.2 • Published 10 years ago

hydrant v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
10 years ago

Hydrant

Hydrate HTTP APIs and generate JSON fixtures from the results

Installation

$ npm install -g hydrant

Usage

Create a file containing a list of hydration steps and invoke bin/hydrant on a target API:

$ hydrant --url=http://localhost:8080 examples/create_session
{
  "user": {
    "_src": "./create_session.js",
    "id": "129",
    "subscriptions": []
  },
  "session": {
    "_src": "./create_session.js",
    "sessionId": "d1643d4c-09d3-11e4-9182-0090f5d88e66",
    "user": {
      "id": "129",
      "subscriptions": [],
      "orgs": []
    }
  }
}

The fixture will be written to stdout by default. If redirects aren't your thing, the -o will ship directly to an output file:

$ hydrant -o my_new_user.js examples/create_session

Fixtures can be broken down into multiple files:

$ hydrant examples/create_session examples/create_course

API

Hydrant exposes a simple node.js API:

hydrant(options, cb);

Options

* `url` {String} - the base url of the target API
* `steps` {Array} - a list of hydration steps to run

Example

var hydrant = require('hydrant');

hydrant({
  url: 'http://localhost:8080',
  steps: [
    require('./examples/create_session')
  ]
}, function (err, fixtures) {
  if (err) throw err;
  console.log(fixtures);
});