From 3be7d969016af35e5136e9ed513395755aaf07a0 Mon Sep 17 00:00:00 2001 From: Mats van Reenen Date: Mon, 17 Dec 2018 19:20:06 +0100 Subject: [PATCH] overall improve ments --- .gitignore | 2 ++ README.md | 2 ++ etc/actions/set.js | 4 ++-- etc/devices.js | 1 + etc/index.js | 1 - setup.sh | 3 +++ 6 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 README.md create mode 100644 setup.sh diff --git a/.gitignore b/.gitignore index e69de29..805f206 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ + +*/nodem_moduels diff --git a/README.md b/README.md new file mode 100644 index 0000000..f6bc9b0 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# MR-IoT +> A server how redirect all action request for home automation IoT devices to the device with a really easy REST API. diff --git a/etc/actions/set.js b/etc/actions/set.js index 5ef0436..105ed90 100644 --- a/etc/actions/set.js +++ b/etc/actions/set.js @@ -15,9 +15,9 @@ module.exports = function(query){ if(query.hasOwnProperty(query.device.values[i].name)){ var value = query[query.device.values[i].name] - switch (query.device.value[i].type) { + switch (query.device.values[i].type) { case "number": - if(value > query.device.value[i].max){ + if(value > query.device.values[i].max){ return 3 // ERROR 3: invalid value } break; diff --git a/etc/devices.js b/etc/devices.js index 6c68f07..0072679 100644 --- a/etc/devices.js +++ b/etc/devices.js @@ -1,4 +1,5 @@ +// TODO: get data from a database devices = { simulation: { addr: "localhost:8081", diff --git a/etc/index.js b/etc/index.js index bbbdcb3..9722657 100644 --- a/etc/index.js +++ b/etc/index.js @@ -16,7 +16,6 @@ var server = http.createServer(function (req, res) { } // split dirrectory and query from url - // TODO: accept GET and POST. [dir, queryTmp] = req.url.split(/\?(.+)/) if(!queryTmp){ queryTmp = req.read(); diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..fb9aebc --- /dev/null +++ b/setup.sh @@ -0,0 +1,3 @@ +#/bin/bash +cd etc +npm install