decms-client

DeCMS client

npm install decms-client
2 downloads in the last week
4 downloads in the last month

DeCMS Client

The DeCMS client consists of a client API and a CLI tool. It also supplies a test script that can be run against a DeCMS server.

API

var decms = require('decms-client'),
  client = new decms.Client('http://127.0.0.1:8080', 'ip');

client.get("search", {q:"sport"}, function(error, result) {
  console.log(error, result.response.docs);
});
  • Client(host, access_token)
  • Client.get(path, [parameters], callback(error, result))
  • Client.post(path, [parameters], data, callback(error, result))
  • Client.put(path, [parameters], data, callback(error, result))
  • Client.delete(path, [parameters], callback(error, result))

parameters should be an object with key-value pairs. data should either be an object that will be serialized as JSON, or a readable stream that will be piped.

The callback result will be the parsed JSON response from DeCMS. If we failed to parse the raw response it will be available on the error object as rawResponse.

CLI

Communicate with DeCMS: decms [options] [method] path method should be one of "get", "post", "put" or "delete" and will default to "get" if not provided.

Options

--help              Displays this help                                                               [boolean]
-t, --access_token  Access token, can also be supplied as a DECMS_ACCESS_TOKEN environment variable  [default: "ip"]
-h, --host          DeCMS host, can also be supplied as a DECMS_HOST environment variable            [default: "http://e.tv2.dk:8080"]
-f, --file          Load data from file
-u, --uri           Resolve the path as a document uri.                                              [boolean]
-p, --pretty        Prints prettified human readable JSON                                            [boolean]

Examples

Get document: $ decms document/3dba0b213c0d0e57f42301605bcd097897826fa6

...document by uri: $ decms --uri tvtid://program/25/27774915

Search: $ decms search?q=hugo

Post a document: $ ./bin/decms.js post document --file document.json

Test suite

DeCMS client provides a test suite that can be run using decms_test.

  • create_webhook_tokens - Creates two access tokens to use for webhook subscriptions.
  • set_up_webhooks - Registers webhook subscriptions for the tokens and sets up
  • write_docs - Writes a couple of documents to DeCMS.
  • read_docs - Reads the documents to verify that they were written.
  • check_taxonomy_channel - Checks that the documents have appeared in the proper channel.
  • delete_docs - Deletes the documents
  • verify_deleted - Verifies that we now get 404 for all the documents.
  • check_webhook_results - Checks if we got both create and delete events for all the documents.
  • tear_down_webhooks - Unregister subscriptions and stop the webhook servers.
  • delete_webhook_tokens
  • empty_taxonomy_channel

Options

--help              Displays this help                                                               [boolean]
-t, --access_token  Access token, can also be supplied as a DECMS_ACCESS_TOKEN environment variable  [default: "ip"]
-h, --host          DeCMS host, can also be supplied as a DECMS_HOST environment variable            [default: "http://e.tv2.dk:8080"]
npm loves you