Skip to content
Adam Magaluk edited this page Jan 20, 2016 · 4 revisions

Class: Zetta

This is the base module for Zetta. It is accessed by using require('zetta') in node. This class exposes functionality for standing up your Zetta server, and linking to the cloud.

Zetta Options
  • registry DeviceRegistry Class - Used to override default DeviceRegistry. See zetta-memory-registry for example.
  • peerRegistry PeerRegistry Class - Used to override default PeerRegistry. See zetta-memory-registry for example.
  • tls Object - Include TLS options to the http/https server exposed by zetta.
var zetta = require('zetta');

var options = {
  tls: {
    key: fs.readFileSync('./key.pem'),
    cert: fs.readFileSync('./cert.pem')
  }
};

zetta(options)
  .listen(443)
Method: name(name)
  • name String

Give your zetta instance a human readable name. This will be exposed in the API using the name property.

var zetta = require('zetta');

zetta()
  .name('detroit');
Method: silent()

Suppress logging messages.

var zetta = require('zetta');

zetta()
  .silent()
Method: logger(logFunction)
  • logFunction Function

Implement a custom logger for Zetta.

var zetta = require('zetta');

zetta()
  .logger(function(log) {
    log.on('message', function(level, event, msg, data) {
      //Intercept logging messages.  
    });
  })
Method: use(constructor, [args], [options])
  • constructor Function
  • [args] list of arguments
  • [options] Object

Load a device driver into Zetta. These can be custom drivers that you've written, or drivers retrieved from npm.

var zetta = require('zetta');
var arduino = require('arduino');

zetta()
  .use(arduino);
Method: use(app)
  • app Function - signature function(server){}

Load a zetta app from another module. An app can be a coordination between devices, or a server extension.

var zetta = require('zetta');
var myApp = require('./myapp.js');

zetta()
  .use(myApp);
Method: link(host)
  • host String or Array of Strings

Link to another Zetta instance. Typically this is used to link your local instance of Zetta to the cloud.

var zetta = require('zetta');

zetta();
  .link('http://zettajs.io/cloud');
Method: listen(port, [hostname], [callback])
  • port Number
  • hostname String
  • callback Function

Select which port your instance of Zetta will listen on locally.

var zetta = require('zetta');

zetta()
  .listen(3000, function(err) {
    console.log('Server listening on port 3000');
  });
Clone this wiki locally