gekoq

1.7.0 • Public • Published

gekoq

A thin wrapper for pushing to Geckoboard's custom widgets using Node.js. Requires Node >=4.0.0

gekoq comes from the Malay word for gecko, said to be imitative of its sound.

See Change Log below.

Install & Usage

$ npm install gekoq

The default exported value is a Function that accepts the Geckoboard API key. This then returns a Function that accepts an Object with the properties key and data and when evaluated pushes to the widget. This returns a Promise.

E.g.

const gekoq = require('gekoq');

const push = gekoq('a094dabc561c521f81782627f1c2by73');

push({
  key: '147539-72d8b6cf-8766-4ead-bd1e-b671e8a5ab86',
  data: { item: [{ value: 1200 }] }
})
.then(response => console.log(response));

A good strategy is to store keys as environment variables. In the terminal (or add to your .{bash,zsh}rc):

$ export GECKOBOARD_API_KEY=a094dabc561c521f81782627f1c2by73

then

const push = gekoq(process.env.GECKOBOARD_API_KEY);

Use Promises to push an array of widgets

const dashboard = [
  {
    key: '119097-1c74815e-8658-48a0-80f3-cdb79a07754c',
    data: { item: [ { value: 100 } ] }
  },
  {
    key: '145647-f084514b-27dc-4552-a267-e6e3cc069baf',
    data: { item: [ { value: 200 } ] }
  }
]

Promise.all(dashboard.map(push)).then(...);

Change Log

1.6.0

Fixed the 'Content-Length' header which used previously the value returned from String.prototype.length. This causes problems when a character has two code points. Now using Buffer.byteLength.

1.5.x

Node 5 build. The default export now returns a Function which expects the Geckoboard API key and returns a Function that expects an Object with the properties key and data. The returned Function is thenable (i.e. it returns a Promise).

1.0.x

Introduced the breaking change whereby gekoq.push now accepts an Object with the required properties key and data (where previously it expected id instead of key). This was done to match the name that Geckoboard refers to this property in the widget configuration.

Dependents (1)

Package Sidebar

Install

npm i gekoq

Weekly Downloads

38

Version

1.7.0

License

MIT

Last publish

Collaborators

  • jasonmendes