New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

homenode-node

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homenode-node - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

70

homenode.js

@@ -12,2 +12,22 @@ var express = require('express');

function getDeviceIndex(id) {
var idx=-1;
devices.forEach(function(dev,i) {
if( dev.id==id ) {
idx=i;
}
});
return idx;
}
function getDeviceAction(device,actionname) {
var action;
device.actions.forEach(function(a) {
if( a.name == actionname ) {
action=a;
}
});
return action;
}
function addDevice(device) {

@@ -19,9 +39,28 @@ devices.push(device);

var getDevice = function(req,res) {
var idx = getDeviceIndex(req.params.deviceid);
if( idx==-1 ) {
res.sendStatus(404);
} else {
res.send(devices[idx]);
}
}
var executeDeviceAction = function(req,res) {
var idx = getDeviceIndex(req.params.deviceid);
if( idx==-1 ) {
res.sendStatus(404);
} else {
var action = getDeviceAction(devices[idx],req.params.actionname);
if( action ) {
action.use();
res.sendStatus(200);
} else {
res.sendStatus(404);
}
}
}
function removeDevice(id) {
var idx=-1;
devices.forEach(function(dev,i) {
if( dev.id==id ) {
idx=i;
}
});
var idx=getDeviceIndex(id);
if( idx!=-1 ) {

@@ -64,2 +103,19 @@ devices.splice(idx,1);

},
device: {
path : "devices/:deviceid",
description : "Gets a device by id",
parameter : {
deviceid : { description : "Device ID", path : true }
},
use : getDevice
},
deviceAction: {
path : "devices/:deviceid/:actionname",
description : "Executes a device action",
parameter : {
deviceid : { description : "Device ID", path : true },
actionname : { description : "Action name", path : true }
},
use : executeDeviceAction
},
heartbeat : {

@@ -91,3 +147,3 @@ description : 'Heartbeat endpoint service',

server.listen(port);
log('Http node listener for ""'+name+'"" started on port '+port);
log('Http node listener for "'+name+'" started on port '+port);

@@ -94,0 +150,0 @@ master.init(port, id, name);

2

package.json
{
"name": "homenode-node",
"version": "0.0.2",
"version": "0.0.3",
"description": "Homenode node library",

@@ -5,0 +5,0 @@ "main": "homenode.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc