From 650150abf2728a67c7d942fdbca17d488f198c13 Mon Sep 17 00:00:00 2001 From: Marvin Roger Date: Thu, 13 Apr 2017 09:44:52 +0200 Subject: [PATCH] :art: Make use of object shorthand --- lib/api_formats/siren/device.siren.js | 6 +-- lib/api_formats/siren/devices.siren.js | 2 +- lib/api_formats/siren/server.siren.js | 2 +- lib/api_resources/devices.js | 2 +- lib/api_resources/peer_management.js | 2 +- lib/api_resources/root.js | 6 +-- lib/api_resources/servers.js | 20 ++++---- lib/event_broker.js | 2 +- lib/event_socket.js | 2 +- lib/http_scout.js | 2 +- lib/http_server.js | 14 +++--- lib/peer_socket.js | 2 +- lib/pubsub_service.js | 2 +- lib/registry.js | 2 +- lib/runtime.js | 2 +- test/fixture/mem_peer_registry.js | 2 +- test/fixture/mem_registry.js | 2 +- test/test_api.js | 34 ++++++------- test/test_compactor.js | 2 +- test/test_driver.js | 2 +- test/test_event_broker.js | 2 +- test/test_event_streams.js | 68 +++++++++++++------------- test/test_event_ws_connection.js | 6 +-- test/test_event_ws_proxied.js | 2 +- test/test_metadata_api.js | 2 +- test/test_peer_connection_api.js | 16 +++--- test/test_peer_events.js | 2 +- test/test_peer_registry.js | 2 +- test/test_peer_websocket.js | 4 +- test/test_query_api.js | 18 +++---- test/test_registry.js | 2 +- test/test_remote_query.js | 2 +- test/test_scout.js | 4 +- test/test_virtual_device.js | 2 +- test/test_zetta.js | 56 ++++++++++----------- zetta.js | 4 +- 36 files changed, 151 insertions(+), 151 deletions(-) diff --git a/lib/api_formats/siren/device.siren.js b/lib/api_formats/siren/device.siren.js index a6f12b5..292bf59 100644 --- a/lib/api_formats/siren/device.siren.js +++ b/lib/api_formats/siren/device.siren.js @@ -10,8 +10,8 @@ module.exports = context => { const properties = model.properties(); const entity = { class: ['device', properties.type], - properties: properties, - actions: actions, + properties, + actions, links: [{ rel: ['self', 'edit'], href: env.helpers.url.path(`${loader.path}/devices/${model.id}`) }, { title: context.serverName, rel: ['up', rel.server], href: env.helpers.url.path(loader.path) }, { rel: [rel.type, 'describedby'], href: `${env.helpers.url.path(loader.path)}/meta/${properties.type}` }] @@ -33,7 +33,7 @@ var buildActions = module.exports.buildActions = (deviceId, env, loader, transit name: type, method: 'POST', href: env.helpers.url.path(`${loader.path}/devices/${deviceId}`), - fields: fields + fields }; if (!actions) { actions = []; diff --git a/lib/api_formats/siren/devices.siren.js b/lib/api_formats/siren/devices.siren.js index e429e82..bb628e7 100644 --- a/lib/api_formats/siren/devices.siren.js +++ b/lib/api_formats/siren/devices.siren.js @@ -27,7 +27,7 @@ var buildEntity = function(model, loader, env) { const entity = { class: ['device', properties.type], rel: [rel.device], - properties: properties, + properties, links: [{ rel: ['self', 'edit'], href: env.helpers.url.path(`${loader.path}/devices/${model.id}`) }, { rel: [rel.type, 'describedby'], href: `${env.helpers.url.path(loader.path)}/meta/${encodeURIComponent(properties.type)}` }, { rel: ['up', rel.server], href: env.helpers.url.path(loader.path) }] diff --git a/lib/api_formats/siren/server.siren.js b/lib/api_formats/siren/server.siren.js index e2b4a05..4299a20 100644 --- a/lib/api_formats/siren/server.siren.js +++ b/lib/api_formats/siren/server.siren.js @@ -59,7 +59,7 @@ var buildEntity = function(model, server, loader, env) { const entity = { class: ['device', properties.type], rel: [rel.device], - properties: properties, + properties, links: [{ rel: ['self', 'edit'], href: env.helpers.url.path(`${loader.path}/devices/${model.id}`) }, { rel: [rel.type, 'describedby'], href: `${env.helpers.url.path(loader.path)}/meta/${encodeURIComponent(properties.type)}` }, { title: server._name, rel: ['up', rel.server], href: env.helpers.url.path(loader.path) }] diff --git a/lib/api_resources/devices.js b/lib/api_resources/devices.js index 7a7407a..f6a5c53 100644 --- a/lib/api_resources/devices.js +++ b/lib/api_resources/devices.js @@ -22,7 +22,7 @@ DevicesResource.prototype.list = function(env, next) { const serverId = match && match[1] ? match[1] : this.server.id; const localServer = { path: `/servers/${encodeURI(serverId)}` }; - const context = { devices: this.server.runtime._jsDevices, loader: localServer, env: env }; + const context = { devices: this.server.runtime._jsDevices, loader: localServer, env }; env.format.render('devices', context); next(env); }; diff --git a/lib/api_resources/peer_management.js b/lib/api_resources/peer_management.js index ebba168..a139df2 100644 --- a/lib/api_resources/peer_management.js +++ b/lib/api_resources/peer_management.js @@ -198,7 +198,7 @@ PeerManagementResource.prototype._proxyToPeer = (peer, env, callback) => { const req = env.request; const res = env.response; const agent = env.zettaAgent || peer.agent; - const opts = { method: req.method, headers: req.headers, path: req.url, agent: agent }; + const opts = { method: req.method, headers: req.headers, path: req.url, agent }; const request = http.request(opts, res => { res.on('data', () => {}); res.on('end', () => { diff --git a/lib/api_resources/root.js b/lib/api_resources/root.js index 37e5a12..3c70e6b 100644 --- a/lib/api_resources/root.js +++ b/lib/api_resources/root.js @@ -104,7 +104,7 @@ RootResource.prototype.list = function(env, next) { const entity = { class: ['device', properties.type], rel: [rel.device], - properties: properties, + properties, links: [{ rel: ['self'], href: env.helpers.url.path(`${loader.path}/devices/${model.id}`) }, { title: server._name, rel: ['up', rel.server], href: env.helpers.url.path(loader.path) }] }; @@ -233,9 +233,9 @@ RootResource.prototype._queryDevices = function(env, next) { const context = { server: self.server, - devices: devices, + devices, loader: {path: `/servers/${encodeURI(self.server.id)}`}, - env: env, + env, classes:['search-results'], query: params.ql }; diff --git a/lib/api_resources/servers.js b/lib/api_resources/servers.js index 3165068..3dd3abd 100644 --- a/lib/api_resources/servers.js +++ b/lib/api_resources/servers.js @@ -178,7 +178,7 @@ ServerResource.prototype.showMetadata = function(env, next) { server: this.server, types: this.deviceTypes, loader: this.getServer(env), - env: env + env }; env.format.render('metadata', context); @@ -202,9 +202,9 @@ ServerResource.prototype.showMetadataType = function(env, next) { const context = { server: this.server, - type: type, + type, loader: this.getServer(env), - env: env + env }; env.format.render('type', context); @@ -221,7 +221,7 @@ ServerResource.prototype.showServer = function(env, next) { } //TODO: argo-formatter may want to take multiple arguments for a format. This context obj is a hack. - const context = { server: this.server, devices: this.server.runtime._jsDevices, loader: this.getServer(env), env: env }; + const context = { server: this.server, devices: this.server.runtime._jsDevices, loader: this.getServer(env), env }; env.format.render('server', context); next(env); }; @@ -290,9 +290,9 @@ ServerResource.prototype._queryDevices = function(env, next) { const context = { server: self.server, - devices: devices, + devices, loader: self.getServer(env), - env: env, + env, classes:['search-results'], query: params.ql }; @@ -361,7 +361,7 @@ ServerResource.prototype.showDevice = function(env, next) { model: device, loader: this.getServer(env), serverName: this.server._name, - env: env + env }; env.format.render('device', model); @@ -420,7 +420,7 @@ ServerResource.prototype.updateDevice = function(env, next) { model: device, loader: self.getServer(env), serverName: self.server._name, - env: env + env }; env.format.render('device', model); @@ -535,7 +535,7 @@ ServerResource.prototype.deviceAction = function(env, next) { env.response.statusCode = statusCode; env.response.body = { class: ['action-error'], - properties: properties, + properties, links: [ { rel: ['self'], href: env.helpers.url.current() } ] @@ -545,7 +545,7 @@ ServerResource.prototype.deviceAction = function(env, next) { model: device, loader: self.getServer(env), serverName: self.server._name, - env: env + env }; env.format.render('device', model); } diff --git a/lib/event_broker.js b/lib/event_broker.js index d5cae1e..069149f 100644 --- a/lib/event_broker.js +++ b/lib/event_broker.js @@ -371,7 +371,7 @@ EventBroker.prototype.subscribeToDeviceQuery = function(topic) { const q = self.zetta.runtime.query().ql(qt.ql); this._deviceQueries[topic] = this.zetta.runtime.observe(q, device => { setImmediate(() => { - self.zetta.pubsub.publish(topic, { query: topic, device: device }); + self.zetta.pubsub.publish(topic, { query: topic, device }); }); }); }; diff --git a/lib/event_socket.js b/lib/event_socket.js index 5019f5d..7ad381f 100644 --- a/lib/event_socket.js +++ b/lib/event_socket.js @@ -118,7 +118,7 @@ const EventSocket = module.exports = function(ws, query, options) { } } - const subscription = { subscriptionId: ++self._subscriptionIndex, topic: topic, limit: msg.limit }; + const subscription = { subscriptionId: ++self._subscriptionIndex, topic, limit: msg.limit }; self._subscriptions.push(subscription); var msg = { diff --git a/lib/http_scout.js b/lib/http_scout.js index 658e860..19a9dcc 100644 --- a/lib/http_scout.js +++ b/lib/http_scout.js @@ -13,7 +13,7 @@ HTTPScout.prototype.init = next => { HTTPScout.prototype.createHTTPDevice = function(type, id, name) { const constructor = this.driverFunctions[type]; - const deviceObject = { id: id, name: name}; + const deviceObject = { id, name}; if(constructor) { if(id) { this.provision(deviceObject, constructor); diff --git a/lib/http_server.js b/lib/http_server.js index 4291a32..775f898 100644 --- a/lib/http_server.js +++ b/lib/http_server.js @@ -306,17 +306,17 @@ ZettaHttpServer.prototype.setupPeerSocket = function(ws) { peer.on('connected', () => { self.eventBroker.peer(peer); self.zetta.log.emit('log', 'http_server', `Peer connection established "${name}".`); - self.zetta.pubsub.publish('_peer/connect', { peer: peer }); + self.zetta.pubsub.publish('_peer/connect', { peer }); }); peer.on('error', err => { self.zetta.log.emit('log', 'http_server', `Peer connection failed for "${name}": ${err.message}.`); - self.zetta.pubsub.publish('_peer/disconnect', { peer: peer, err: err }); + self.zetta.pubsub.publish('_peer/disconnect', { peer, err }); }); peer.on('end', () => { self.zetta.log.emit('log', 'http_server', `Peer connection closed for "${name}".`); - self.zetta.pubsub.publish('_peer/disconnect', { peer: peer }); + self.zetta.pubsub.publish('_peer/disconnect', { peer }); }); } }; @@ -460,12 +460,12 @@ ZettaHttpServer.prototype.proxyToPeers = function(peers, env, cb) { const agent = env.zettaAgent || peer.agent; - const opts = { method: req.method, headers: headers, path: reqUrl, agent: agent }; + const opts = { method: req.method, headers, path: reqUrl, agent }; const request = http.request(opts, response => { response.getBody((err, body) => { - callback(null, { res: response, err: err, body: body }); + callback(null, { res: response, err, body }); }); - }).on('error', err => callback(null, { err: err })); + }).on('error', err => callback(null, { err })); if (req.body) { request.end(req.body); @@ -505,7 +505,7 @@ ZettaHttpServer.prototype.proxyToPeer = function(env, next) { method: req.method, headers: req.headers, path: req.url, - agent: agent, + agent, pipe: true }; if (typeof env.proxyOpts === 'object') { diff --git a/lib/peer_socket.js b/lib/peer_socket.js index 3eb168a..3db55f6 100644 --- a/lib/peer_socket.js +++ b/lib/peer_socket.js @@ -394,7 +394,7 @@ PeerSocket.prototype.transition = function(action, args, cb) { const opts = { agent: this.agent, - path: path, + path, method: action.method, headers: { 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/lib/pubsub_service.js b/lib/pubsub_service.js index 6953006..036918b 100644 --- a/lib/pubsub_service.js +++ b/lib/pubsub_service.js @@ -129,7 +129,7 @@ PubSub.prototype._onResponse = function(topic, sourceTopic, data, fromRemote, en } else if (data.query && data.device) { var serverId = env.route.params.serverId; const loader = { path: `/servers/${encodeURIComponent(serverId)}` }; - data = deviceFormatter({ loader: loader, env: env, model: data.device }); + data = deviceFormatter({ loader, env, model: data.device }); encoding = 'application/json'; data = new Buffer(JSON.stringify(data)); } else if (typeof data == 'object') { diff --git a/lib/registry.js b/lib/registry.js index d22e369..2323ec8 100644 --- a/lib/registry.js +++ b/lib/registry.js @@ -31,7 +31,7 @@ Registry.prototype._init = function(cb) { }); const engine = calypso.configure({ - driver: driver + driver }); engine.build((err, connection) => { diff --git a/lib/runtime.js b/lib/runtime.js index 4752342..b9ec17b 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -266,7 +266,7 @@ Runtime.prototype._initRemoteQueryListener = function(ql, peer) { this._remoteSubscriptions[peer.name] = {}; } - const topic = querytopic.format({ql: ql}); + const topic = querytopic.format({ql}); // already subscribed to the query topic if(this._remoteSubscriptions[peer.name][topic]) { diff --git a/test/fixture/mem_peer_registry.js b/test/fixture/mem_peer_registry.js index 34efadf..d182d83 100644 --- a/test/fixture/mem_peer_registry.js +++ b/test/fixture/mem_peer_registry.js @@ -5,7 +5,7 @@ const PeerRegistry = require('../../lib/peer_registry'); const MemPeerRegistry = module.exports = function() { const db = levelup({ db: memdown }); - PeerRegistry.call(this, { db: db, collection: 'peers' }); + PeerRegistry.call(this, { db, collection: 'peers' }); }; util.inherits(MemPeerRegistry, PeerRegistry); diff --git a/test/fixture/mem_registry.js b/test/fixture/mem_registry.js index a95be4a..0c43ac0 100644 --- a/test/fixture/mem_registry.js +++ b/test/fixture/mem_registry.js @@ -5,7 +5,7 @@ const DeviceRegistry = require('../../lib/device_registry'); const MemRegistry = module.exports = function() { const db = levelup({ db: memdown }); - DeviceRegistry.call(this, { db: db, collection: 'devices' }); + DeviceRegistry.call(this, { db, collection: 'devices' }); }; util.inherits(MemRegistry, DeviceRegistry); diff --git a/test/test_api.js b/test/test_api.js index 7fc4e70..c8bdfa8 100644 --- a/test/test_api.js +++ b/test/test_api.js @@ -83,7 +83,7 @@ describe('Zetta Api', () => { }); it('updates href hosts using x-forwarded-host header', done => { - const app = zetta({ registry: reg, peerRegistry: peerRegistry }) + const app = zetta({ registry: reg, peerRegistry }) .silent() .name('local') ._run(err => { @@ -103,7 +103,7 @@ describe('Zetta Api', () => { }) it('updates href path using x-forwarded-path header', done => { - const app = zetta({ registry: reg, peerRegistry: peerRegistry }) + const app = zetta({ registry: reg, peerRegistry }) .silent() .name('local') ._run(err => { @@ -124,7 +124,7 @@ describe('Zetta Api', () => { }) it('allow for x-forwarded-host header to be disabled', done => { - const app = zetta({ registry: reg, peerRegistry: peerRegistry, useXForwardedHostHeader: false }) + const app = zetta({ registry: reg, peerRegistry, useXForwardedHostHeader: false }) .silent() .name('local') ._run(err => { @@ -144,7 +144,7 @@ describe('Zetta Api', () => { }) it('allow for x-forwarded-path header to be disabled', done => { - const app = zetta({ registry: reg, peerRegistry: peerRegistry, useXForwardedPathHeader: false }) + const app = zetta({ registry: reg, peerRegistry, useXForwardedPathHeader: false }) .silent() .name('local') ._run(err => { @@ -173,7 +173,7 @@ describe('Zetta Api', () => { let url = null; beforeEach(done => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .properties({ custom: 123 }) .use(Scout) @@ -276,7 +276,7 @@ describe('Zetta Api', () => { host: '127.0.0.1', port: a.address().port, path: url, - agent: agent + agent }, response => { const buffers = []; @@ -318,7 +318,7 @@ describe('Zetta Api', () => { host: '127.0.0.1', port: a.address().port, path: '/', - agent: agent + agent }, response => { const buffers = []; @@ -422,7 +422,7 @@ describe('Zetta Api', () => { let app = null; beforeEach(() => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -481,7 +481,7 @@ describe('Zetta Api', () => { }); it('should use a default server name if none has been provided', done => { - const app = zetta({ registry: reg, peerRegistry: peerRegistry }).silent()._run(); + const app = zetta({ registry: reg, peerRegistry }).silent()._run(); request(getHttpServer(app)) .get('/') @@ -505,7 +505,7 @@ describe('Zetta Api', () => { }); beforeEach(done => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -620,7 +620,7 @@ describe('Zetta Api', () => { describe('#show', () => { it('should return the peer item representation', done => { const id = '1234-5678-9ABCD'; - peerRegistry.save({ id: id }, () => { + peerRegistry.save({ id }, () => { request(getHttpServer(app)) .get(`/peer-management/${id}`) .expect(200, done); @@ -633,7 +633,7 @@ describe('Zetta Api', () => { let app = null; beforeEach(done => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -712,7 +712,7 @@ describe('Zetta Api', () => { let device = null; beforeEach(done => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -887,7 +887,7 @@ describe('Zetta Api', () => { host: '127.0.0.1', port: a.address().port, path: url, - agent: agent + agent }, response => { const buffers = []; @@ -970,7 +970,7 @@ describe('Zetta Api', () => { .post(url) .type('form') .expect(200) - .send({ action: action, value: input }) + .send({ action, value: input }) .end(done); }); }; @@ -1206,7 +1206,7 @@ describe('Zetta Api', () => { let cluster = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('detroit', [Scout], ['cloud']) .server('sanjose', [Scout], ['cloud']) @@ -1276,7 +1276,7 @@ describe('Zetta Api', () => { const hubName = 'hub 1'; const getServer = peerName => cluster.servers[peerName].httpServer.server; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server(hubName, [Scout], ['cloud']) .on('ready', done) diff --git a/test/test_compactor.js b/test/test_compactor.js index ce99a15..e2bbf56 100644 --- a/test/test_compactor.js +++ b/test/test_compactor.js @@ -13,7 +13,7 @@ describe('Registry Compaction', () => { beforeEach(done => { db = levelup(dbPath, { db: memdown }); - opts = { db: db, collection: 'peers' }; + opts = { db, collection: 'peers' }; done(); }); diff --git a/test/test_driver.js b/test/test_driver.js index fa46299..aecc3fb 100644 --- a/test/test_driver.js +++ b/test/test_driver.js @@ -18,7 +18,7 @@ describe('Driver', () => { beforeEach(() => { reg = new MemRegistry(); pubsub = new PubSub(); - log = new Logger({pubsub: pubsub}); + log = new Logger({pubsub}); log.pubsub = pubsub; // create machine machine = Scientist.create(TestDriver); diff --git a/test/test_event_broker.js b/test/test_event_broker.js index bc1b6a0..7e871bc 100644 --- a/test/test_event_broker.js +++ b/test/test_event_broker.js @@ -30,7 +30,7 @@ describe('EventBroker', () => { beforeEach(() => { const reg = new Registry(); peerRegistry = new PeerRegistry(); - app = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + app = zetta({ registry: reg, peerRegistry }).silent(); query = { topic: '_peer/connect', name: app.id }; broker = new EventBroker(app); }); diff --git a/test/test_event_streams.js b/test/test_event_streams.js index 8ca2cb1..8c00341 100644 --- a/test/test_event_streams.js +++ b/test/test_event_streams.js @@ -213,7 +213,7 @@ describe('Event Streams', () => { urls = []; devices = []; validTopics = []; - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('hub', [Driver, Driver], ['cloud']) .server('hub2', [Driver, Driver], ['cloud']) @@ -330,7 +330,7 @@ describe('Event Streams', () => { let subscriptionId = null; const topic = validTopics[0]; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -367,7 +367,7 @@ describe('Event Streams', () => { const ws1 = new WebSocket(`ws://${endpoint}${baseUrl}`); ws1.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws1.send(JSON.stringify(msg)); let subscriptionId = null; ws1.on('message', buffer => { @@ -395,7 +395,7 @@ describe('Event Streams', () => { const ws2 = new WebSocket(`ws://${endpoint}${baseUrl}`); ws2.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws2.send(JSON.stringify(msg)); let subscriptionId = null; ws2.on('message', buffer => { @@ -430,7 +430,7 @@ describe('Event Streams', () => { const ws1 = new WebSocket(`ws://${endpoint}${baseUrl}`); ws1.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws1.send(JSON.stringify(msg)); let subscriptionId = null; ws1.on('message', buffer => { @@ -491,7 +491,7 @@ describe('Event Streams', () => { let topic = validTopics[0]; topic = topic.replace('hub', '*'); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -565,7 +565,7 @@ describe('Event Streams', () => { runtime.observe(query, device => { const ws = new WebSocket(`ws://${endpoint}${baseUrl}`); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -603,7 +603,7 @@ describe('Event Streams', () => { runtime.observe(query, device => { const ws = new WebSocket(`ws://${endpoint}${baseUrl}`); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -637,7 +637,7 @@ describe('Event Streams', () => { let subscriptionId = null; const topic = '*/testdriver/*/state'; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); let recv = 0; ws.on('message', buffer => { @@ -683,7 +683,7 @@ describe('Event Streams', () => { }); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -732,7 +732,7 @@ describe('Event Streams', () => { } ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -775,7 +775,7 @@ describe('Event Streams', () => { const topic = 'hub/testdriver/*/state'; let lastTopic = null; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -816,7 +816,7 @@ describe('Event Streams', () => { const topic = 'hub/testdriver/**'; let lastTopic = null; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -855,7 +855,7 @@ describe('Event Streams', () => { let subscriptionId = null; const topic = validTopics[0].replace('hub/', '**/'); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -889,7 +889,7 @@ describe('Event Streams', () => { let subscriptionId = null; const topic = validTopics[0].replace('hub/', '**/'); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -923,7 +923,7 @@ describe('Event Streams', () => { let subscriptionId = null; const topic = validTopics[0].replace('hub/', '**/'); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -958,7 +958,7 @@ describe('Event Streams', () => { const topic = 'hub/testdriver/*/logs'; let lastTopic = null; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -997,7 +997,7 @@ describe('Event Streams', () => { const ws = new WebSocket(`ws://${endpoint}${baseUrl}`); const topic = 'blah/foo/1/blah'; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1016,7 +1016,7 @@ describe('Event Streams', () => { const topic = 'hub/**'; const ws = new WebSocket(`ws://${endpoint}${baseUrl}`); ws.on('open', () => { - ws.send(JSON.stringify({ type: 'subscribe', topic: topic })); + ws.send(JSON.stringify({ type: 'subscribe', topic })); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1116,7 +1116,7 @@ describe('Event Streams', () => { const topic = validTopics[0]; const data = null; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic, limit: 10 }; + const msg = { type: 'subscribe', topic, limit: 10 }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1160,7 +1160,7 @@ describe('Event Streams', () => { const topic = validTopics[0]; const data = null; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic, limit: 10 }; + const msg = { type: 'subscribe', topic, limit: 10 }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1202,7 +1202,7 @@ describe('Event Streams', () => { const topic = `hub/testdriver/${devices[0].id}/bar?select data where data >= 5`; const data = null; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic, limit: 10 }; + const msg = { type: 'subscribe', topic, limit: 10 }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1243,7 +1243,7 @@ describe('Event Streams', () => { const count = 0; const topic = `hub/testdriver/${devices[0].id}/bar?select data where data >= 1`; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1277,7 +1277,7 @@ describe('Event Streams', () => { const topic = `hub/testdriver/${devices[0].id}/fooobject?select * where data.val >= 2`; const data = { foo: 'bar', val: 2 }; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1312,7 +1312,7 @@ describe('Event Streams', () => { const topic = `hub/testdriver/${devices[0].id}/fooobject?select data.val`; const data = { foo: 'bar', val: 2 }; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1344,7 +1344,7 @@ describe('Event Streams', () => { const ws = new WebSocket(`ws://${endpoint}${baseUrl}`); const topic = '**'; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1379,7 +1379,7 @@ describe('Event Streams', () => { const ws = new WebSocket(`ws://${endpoint}${baseUrl}?filterMultiple=true`); const topic = validTopics[0]; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; const msg2 = { type: 'subscribe', topic: 'hub/testdriver/*/state' }; ws.send(JSON.stringify(msg)); ws.send(JSON.stringify(msg2)); @@ -1418,7 +1418,7 @@ describe('Event Streams', () => { const topic = validTopics[0]; const topic2 = 'hub/testdriver/*/state'; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic, limit: 2 }; + const msg = { type: 'subscribe', topic, limit: 2 }; const msg2 = { type: 'subscribe', topic: topic2, limit: 3 }; ws.send(JSON.stringify(msg)); ws.send(JSON.stringify(msg2)); @@ -1462,7 +1462,7 @@ describe('Event Streams', () => { const topic = `${validTopics[0]}?select *`; const topic2 = 'hub/testdriver/*/state'; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; const msg2 = { type: 'subscribe', topic: topic2 }; ws.send(JSON.stringify(msg)); ws.send(JSON.stringify(msg2)); @@ -1501,7 +1501,7 @@ describe('Event Streams', () => { let count = 0; const expected = (idx === 1) ? 2 : 2; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1536,7 +1536,7 @@ describe('Event Streams', () => { let count = 0; const expected = (idx === 1) ? 2 : 4; // cloud will have 4 devices ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1568,7 +1568,7 @@ describe('Event Streams', () => { let subscriptionId = null; const topic = `hub/testdriver/${devices[0].id}/bar`; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1603,7 +1603,7 @@ describe('Event Streams', () => { const endpoint = urls[idx]; const ws = new WebSocket(`ws://${endpoint}${baseUrl}`); ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); @@ -1634,7 +1634,7 @@ describe('Event Streams', () => { const topic = `hub/testdriver/${devices[0].id}/fooobject?invalid stream query`; const data = { foo: 'bar', val: 2 }; ws.on('open', () => { - const msg = { type: 'subscribe', topic: topic }; + const msg = { type: 'subscribe', topic }; ws.send(JSON.stringify(msg)); ws.on('message', buffer => { const json = JSON.parse(buffer); diff --git a/test/test_event_ws_connection.js b/test/test_event_ws_connection.js index 51796e9..354048f 100644 --- a/test/test_event_ws_connection.js +++ b/test/test_event_ws_connection.js @@ -49,7 +49,7 @@ describe('Event Websocket', () => { done(err); return; } - app = zetta({registry: registry, peerRegistry: peerRegistry}); + app = zetta({registry, peerRegistry}); app.silent(); app.name('BC2832FD-9437-4473-A4A8-AC1D56B12C61'); app.use(GoodScout); @@ -125,11 +125,11 @@ describe('Event Websocket', () => { beforeEach(done => { const peerRegistry = new PeerRegistry(); const registry = new MockRegistry(); - app = zetta({registry: registry, peerRegistry: peerRegistry}); + app = zetta({registry, peerRegistry}); app.silent(); app.use(server => { var server = server.httpServer.server; - wss = new WebSocketServer({server: server, path: '/foo'}); + wss = new WebSocketServer({server, path: '/foo'}); }); app.listen(0, err => { port = app.httpServer.server.address().port; diff --git a/test/test_event_ws_proxied.js b/test/test_event_ws_proxied.js index 57dd2d7..7832efc 100644 --- a/test/test_event_ws_proxied.js +++ b/test/test_event_ws_proxied.js @@ -11,7 +11,7 @@ describe('Event Websocket Proxied Through Peer', () => { let device = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud deploy') .server('detroit 1', [Scout], ['cloud deploy']) .on('ready', () => { diff --git a/test/test_metadata_api.js b/test/test_metadata_api.js index 703b070..3c29c54 100644 --- a/test/test_metadata_api.js +++ b/test/test_metadata_api.js @@ -38,7 +38,7 @@ describe('Metadata API', () => { reg = new Registry(); peerRegistry = new PeerRegistry(); - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Driver) .name('local') diff --git a/test/test_peer_connection_api.js b/test/test_peer_connection_api.js index 902bf97..deca024 100644 --- a/test/test_peer_connection_api.js +++ b/test/test_peer_connection_api.js @@ -11,7 +11,7 @@ const querystring = require('querystring'); function deleteRequest(port, connectionId) { const opts = { host: 'localhost', - port: port, + port, method: 'DELETE', path: `/peer-management/${connectionId}` }; @@ -22,12 +22,12 @@ function deleteRequest(port, connectionId) { function putRequest(port, connectionId, url) { const qs = { - url: url + url }; const string = querystring.stringify(qs); const opts = { host: 'localhost', - port: port, + port, method: 'PUT', path: `/peer-management/${connectionId}`, headers: { @@ -68,7 +68,7 @@ describe('Peer Connection API', () => { beforeEach(done => { peerRegistry = new MemPeerRegistry(); - app = zetta({ registry: new MemRegistry(), peerRegistry: peerRegistry }) + app = zetta({ registry: new MemRegistry(), peerRegistry }) .silent() .name('local') ._run(done); @@ -85,8 +85,8 @@ describe('Peer Connection API', () => { const peer = { id:'foo', connectionId:'12345', - direction: direction, - status: status + direction, + status }; peerRegistry.save(peer, () => { @@ -115,8 +115,8 @@ describe('Peer Connection API', () => { const peer = { id:'foo', connectionId:'12345', - direction: direction, - status: status + direction, + status }; peerRegistry.save(peer, () => { const url = '/peer-management/foo'; diff --git a/test/test_peer_events.js b/test/test_peer_events.js index 4f6497f..c3070b7 100644 --- a/test/test_peer_events.js +++ b/test/test_peer_events.js @@ -9,7 +9,7 @@ describe('Peer Connection Events in Pubsub', () => { let cluster = null; const device = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('detroit1', [Scout], ['cloud']); done(); diff --git a/test/test_peer_registry.js b/test/test_peer_registry.js index 7425c8e..2b90a26 100644 --- a/test/test_peer_registry.js +++ b/test/test_peer_registry.js @@ -12,7 +12,7 @@ describe('Peer Registry', () => { beforeEach(done => { db = levelup(dbPath, { db: memdown }); - opts = { db: db, collection: 'peers' }; + opts = { db, collection: 'peers' }; done(); }); diff --git a/test/test_peer_websocket.js b/test/test_peer_websocket.js index 0b33a02..3b74cbf 100644 --- a/test/test_peer_websocket.js +++ b/test/test_peer_websocket.js @@ -9,7 +9,7 @@ describe('Peer Client Websocket', () => { it('it should connect to ws:// server', done => { const server = http.createServer(); - const wss = new WebSocketServer({ server: server }); + const wss = new WebSocketServer({ server }); server.listen(0, err => { if (err) { return done(err); @@ -32,7 +32,7 @@ describe('Peer Client Websocket', () => { }; const server = https.createServer(opts); - const wss = new WebSocketServer({ server: server }); + const wss = new WebSocketServer({ server }); server.listen(0, err => { if (err) { return done(err); diff --git a/test/test_query_api.js b/test/test_query_api.js index 927cd3e..a343627 100644 --- a/test/test_query_api.js +++ b/test/test_query_api.js @@ -101,7 +101,7 @@ describe('Zetta Query Api', () => { let app = null; beforeEach(() => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -141,7 +141,7 @@ describe('Zetta Query Api', () => { let app = null; beforeEach(() => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -194,7 +194,7 @@ describe('Zetta Query Api', () => { let app = null; beforeEach(() => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -247,7 +247,7 @@ describe('Zetta Query Api', () => { let cluster = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('detroit1', [Scout], ['cloud']) .on('ready', () => { @@ -305,7 +305,7 @@ describe('Zetta Query Api', () => { let cluster = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('detroit1', [Scout], ['cloud']) .server('detroit2', [Scout], ['cloud']) @@ -339,7 +339,7 @@ describe('Zetta Query Api', () => { Scientist.init(machine); reg.save(machine, err => { assert.ok(!err); - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -402,7 +402,7 @@ describe('Zetta Query Api', () => { let app = null; beforeEach(() => { - app = zetta({ registry: reg, peerRegistry: peerRegistry }) + app = zetta({ registry: reg, peerRegistry }) .silent() .use(Scout) .name('local') @@ -452,7 +452,7 @@ describe('Zetta Query Api', () => { it('should return empty list if no devices are provisioned on server', done => { - const app = zetta({ registry: reg, peerRegistry: peerRegistry }) + const app = zetta({ registry: reg, peerRegistry }) .silent() .name('local') ._run(); @@ -472,7 +472,7 @@ describe('Zetta Query Api', () => { let cluster = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('detroit1', [Scout], ['cloud']) .on('ready', () => { diff --git a/test/test_registry.js b/test/test_registry.js index 4c340ec..18cd2d1 100644 --- a/test/test_registry.js +++ b/test/test_registry.js @@ -35,7 +35,7 @@ describe('DeviceRegistry', () => { db = levelup(dbPath, { db: memdown }); machine = Scientist.create(TestDriver); Scientist.init(machine); - opts = { db: db, collection: 'devices' }; + opts = { db, collection: 'devices' }; done(); }); diff --git a/test/test_remote_query.js b/test/test_remote_query.js index 21a41e1..05021c8 100644 --- a/test/test_remote_query.js +++ b/test/test_remote_query.js @@ -42,7 +42,7 @@ describe('Remote queries', () => { let urlRoot = null; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud', [Scout]) .server('detroit1', [Scout], ['cloud']) .server('chicago', [Scout], ['cloud']) diff --git a/test/test_scout.js b/test/test_scout.js index 3badc26..33862a9 100644 --- a/test/test_scout.js +++ b/test/test_scout.js @@ -38,7 +38,7 @@ describe('Scout', () => { beforeEach(() => { const registry = new MockRegistry(); - runtime = new Runtime({registry: registry}); + runtime = new Runtime({registry}); }); it('it should pass arguments to device', done => { @@ -102,7 +102,7 @@ describe('Scout', () => { done(err); return; } - runtime = new Runtime({registry: registry}); + runtime = new Runtime({registry}); done(); }); }); diff --git a/test/test_virtual_device.js b/test/test_virtual_device.js index 1f8ca78..b56b6b5 100644 --- a/test/test_virtual_device.js +++ b/test/test_virtual_device.js @@ -28,7 +28,7 @@ describe('Virtual Device', () => { const startPort = 2600; beforeEach(done => { - cluster = zettacluster({ zetta: zetta }) + cluster = zettacluster({ zetta }) .server('cloud') .server('detroit1', [Scout], ['cloud']) .on('ready', () => { diff --git a/test/test_zetta.js b/test/test_zetta.js index 3bb11e0..c774148 100644 --- a/test/test_zetta.js +++ b/test/test_zetta.js @@ -27,18 +27,18 @@ describe('Zetta', () => { }); it('has the name set using the name() function.', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).name('local').silent(); + const z = zetta({ registry: reg, peerRegistry }).name('local').silent(); assert.equal(z._name, 'local'); }); it('should throw error if setting name to *', () => { assert.throws(() => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).name('*').silent(); + const z = zetta({ registry: reg, peerRegistry }).name('*').silent(); }, Error); }); it('has the silent() function to suppress logging.', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).name('local').silent(); + const z = zetta({ registry: reg, peerRegistry }).name('local').silent(); }); it('errors thrown in zetta apps should propagate.', done => { @@ -68,7 +68,7 @@ describe('Zetta', () => { cert: fs.readFileSync(`${__dirname}/fixture/keys/cert.pem`) }; - const z = zetta({ registry: reg, peerRegistry: peerRegistry, tls: options }) + const z = zetta({ registry: reg, peerRegistry, tls: options }) .silent() .listen(0, err => { if (err) return done(err); @@ -76,7 +76,7 @@ describe('Zetta', () => { const port = z.httpServer.server.address().port; const req = https.get({ host: 'localhost', - port: port, + port, path: '/', rejectUnauthorized: false }, res => { @@ -88,7 +88,7 @@ describe('Zetta', () => { }); it('has the logger() function to pass in custom logging.', done => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }); + const z = zetta({ registry: reg, peerRegistry }); z.logger(log => { log.on('message', (level, event, msg, data) => { assert.equal(level, 'info'); @@ -104,7 +104,7 @@ describe('Zetta', () => { it('will load an app with the load() function', done => { - zetta({ registry: reg, peerRegistry: peerRegistry }) + zetta({ registry: reg, peerRegistry }) .silent() .load(server => { assert.ok(server); @@ -114,7 +114,7 @@ describe('Zetta', () => { }); it('will load an app with the use() function', done => { - zetta({ registry: reg, peerRegistry: peerRegistry }) + zetta({ registry: reg, peerRegistry }) .silent() .use(server => { assert.ok(server); @@ -131,7 +131,7 @@ describe('Zetta', () => { done(); }; - zetta({ registry: reg, peerRegistry: peerRegistry }) + zetta({ registry: reg, peerRegistry }) .silent() .use(app, { foo: 1}) ._initApps(() => { @@ -148,7 +148,7 @@ describe('Zetta', () => { done(); }; - zetta({ registry: reg, peerRegistry: peerRegistry }) + zetta({ registry: reg, peerRegistry }) .silent() .use(app, 1, 2) ._initApps(() => { @@ -157,7 +157,7 @@ describe('Zetta', () => { }); it('will load a driver with the use() function', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); function TestDriver() { Device.call(this); } @@ -171,7 +171,7 @@ describe('Zetta', () => { }); it('will load an HTTP driver with the use() function', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); function TestDriver() { HttpDevice.call(this); } @@ -185,7 +185,7 @@ describe('Zetta', () => { }); it('will load a scout with the use() function', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); function TestScout() { Scout.call(this); } @@ -197,7 +197,7 @@ describe('Zetta', () => { }); it('will set the what query is used for expose()', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); z.expose('*'); assert.ok(z._exposeQuery); @@ -210,7 +210,7 @@ describe('Zetta', () => { }; MockHttp.prototype.listen = port => {}; - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); z.httpServer = new MockHttp(); z.listen(0); @@ -224,7 +224,7 @@ describe('Zetta', () => { done(); }; - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); z.httpServer = new MockHttp(); z.listen(0); @@ -238,7 +238,7 @@ describe('Zetta', () => { cb(null); }; - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).silent(); + const z = zetta({ registry: reg, peerRegistry }).silent(); z.httpServer = new MockHttp(); z.listen(0, err => { assert.ok(!err); @@ -247,7 +247,7 @@ describe('Zetta', () => { }); it('should initialize device with proper properties set.', done => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }) + const z = zetta({ registry: reg, peerRegistry }) .silent() .use(ExampleDevice, 1, 'a') ._run(err => { @@ -261,7 +261,7 @@ describe('Zetta', () => { }); it('should initialize 3 devices with correct params when using multiple use', done => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }) + const z = zetta({ registry: reg, peerRegistry }) .silent() .use(ExampleDevice, 1, 'a') .use(ExampleDevice, 2, 'b') @@ -287,7 +287,7 @@ describe('Zetta', () => { it('should provision 3 devices already in registry with correct params when using multiple use', done => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }) + const z = zetta({ registry: reg, peerRegistry }) .silent() .use(ExampleDevice, 1, 'a') .use(ExampleDevice, 2, 'b') @@ -314,7 +314,7 @@ describe('Zetta', () => { assert(find(2, 'b')); assert(find(3, 'c')); - const z2 = zetta({ registry: reg, peerRegistry: peerRegistry }) + const z2 = zetta({ registry: reg, peerRegistry }) .silent() .use(ExampleDevice, 1, 'a') .use(ExampleDevice, 2, 'b') @@ -345,7 +345,7 @@ describe('Zetta', () => { return oldInit.call(this, config); }; - const app = zetta({ peerRegistry: peerRegistry, registry: reg }); + const app = zetta({ peerRegistry, registry: reg }); app.silent(); app.use(ExampleDevice); app.listen(0); @@ -358,7 +358,7 @@ describe('Zetta', () => { describe('peering', () => { it('.link should add to peers', done => { - const app = zetta({ peerRegistry: peerRegistry, registry: reg }); + const app = zetta({ peerRegistry, registry: reg }); app.silent(); app.link('http://example.com/'); app._initPeers(app._peers, err => { @@ -395,7 +395,7 @@ describe('Zetta', () => { it('.link should not add to peers', done => { peerRegistry.db.put('1234567', JSON.stringify({id: '1234567', direction: 'initiator', url: 'http://example.com/', fromLink: true}), err => { - const app = zetta({ peerRegistry: peerRegistry, registry: reg }); + const app = zetta({ peerRegistry, registry: reg }); app.silent(); app._initPeers(app._peers, err => { setTimeout(() => { @@ -408,7 +408,7 @@ describe('Zetta', () => { it('will delete fromLink peers in the registry', done => { peerRegistry.db.put('1234567', JSON.stringify({ id:'1234567', direction: 'initiator', url: 'http://example.com/', fromLink: true}), err => { - const app = zetta({ peerRegistry: peerRegistry, registry: reg }); + const app = zetta({ peerRegistry, registry: reg }); app._initPeers(app._peers, err => { setTimeout(() => { assert.equal(app._peerClients.length, 0); @@ -425,7 +425,7 @@ describe('Zetta', () => { it('will init API peers.', done => { peerRegistry.db.put('1234567', JSON.stringify({id: '1234567', direction: 'initiator', url: 'http://example.com/'}), err => { - const app = zetta({ peerRegistry: peerRegistry, registry: reg }); + const app = zetta({ peerRegistry, registry: reg }); app.silent(); app._initPeers(app._peers, err => { setTimeout(() => { @@ -439,13 +439,13 @@ describe('Zetta', () => { }); it('has the properties() function to add custom properties to the api.', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }); + const z = zetta({ registry: reg, peerRegistry }); assert(typeof z.properties, 'function'); z.properties({ test: 'abc' }); }); it('.getProperties() returns properties.', () => { - const z = zetta({ registry: reg, peerRegistry: peerRegistry }).name('test'); + const z = zetta({ registry: reg, peerRegistry }).name('test'); z.properties({ someKey: 123 }); assert.deepEqual(z.getProperties(), { name: 'test', someKey: 123 }); }); diff --git a/zetta.js b/zetta.js index 8b20b57..687e20a 100644 --- a/zetta.js +++ b/zetta.js @@ -125,7 +125,7 @@ Zetta.prototype.use = function() { machine._registry = self.runtime.registry; const config = scientist.config(machine); - return { config: config, instance: machine }; + return { config, instance: machine }; } function walk(proto) { @@ -451,7 +451,7 @@ Zetta.prototype._runPeer = function(peer) { self.peerRegistry.save(result); // peer-event - self.pubsub.publish('_peer/disconnect', { peer: peerClient, error: error }); + self.pubsub.publish('_peer/disconnect', { peer: peerClient, error }); }); });