5.2.2 • Published 7 years ago

vudash-transports v5.2.2

Weekly downloads
2
License
MIT
Repository
-
Last release
7 years ago

Vudash transports

A data source abstraction for Vudash widgets.

Overview

Vudash transports can be installed as a dependency of any widget to allow a user to pick from a number of sources of data.

This saves time for a widget developer, and means that any widget can easily fetch data from a number of different sources.

Supported sources

Transport nameTransport Data SourceDocumentation
valueconfig { value: <value> }docs/value
randomchance.natural({ min: 0, max: 999})docs/random
resthttp(s) using requestdocs/rest
google-sheetsGoogle Sheetsdocs/google-sheets

Usage (For developers)

  1. In order to use in a widget, install the module: npm i -s vudash-transports
  2. Then simply read the data-source value from the widget's options, and pass it into Transport.configure in your widget's constructor.

    const Transport = require('vudash-transports')
    
    constructor (options) {
      this.transport = Transport.configure(options['data-source'])
    }
  3. To fetch data, just ask the transport for it.

      this.transport.fetch()
      .then((data) => {
        // do something with data
      })

Usage (For widget consumers)

When using a widget which uses vudash-transports, the consumer simply passes in the transport config:

  // my-dashboard.json
  {
    position: [...],
    widget: 'some-widget',
    options: {
      ...
      "data-source": {
        source: 'rest',
        config: {
          url: 'http://example.com/some/api',
          method: 'get',
          graph: 'some.nested.value'
        }
      }
    }
  }

where data-source.source is one of the supported transports listed at the top of this readme, and data-source.config is the transport specific config, such as credentials for third party services, or URLs for web services, etc.

All configuration is validated by a transport method, using Joi.

5.2.2

7 years ago

5.2.1

7 years ago

5.1.1

7 years ago

5.0.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago