diff --git a/routes/heating.js b/routes/heating.js index b3a0926..d9d7592 100644 --- a/routes/heating.js +++ b/routes/heating.js @@ -1,9 +1,22 @@ const post = require('../lib/post') -module.exports = function(app){ +module.exports = function (app) { app.get("/heating", async function (req, res, next) { const response = await post.postRequest() const heating = response.updateData.zones[0] res.json(heating) }); + + app.get("/heating/status", async function (req, res, next) { + const response = await post.postRequest() + const heating = response.updateData.zones[0].status + res.json(heating) + }); + + app.get("/heating/config", async function (req, res, next) { + const response = await post.postRequest() + const heating = response.updateData.zones[0].config + res.json(heating) + }); + } \ No newline at end of file diff --git a/routes/water.js b/routes/water.js new file mode 100644 index 0000000..bcf7f71 --- /dev/null +++ b/routes/water.js @@ -0,0 +1,22 @@ +const post = require('../lib/post') + +module.exports = function (app) { + app.get("/water", async function (req, res, next) { + const response = await post.postRequest() + const water = response.updateData.zones[1] + res.json(water) + }); + + app.get("/water/status", async function (req, res, next) { + const response = await post.postRequest() + const water = response.updateData.zones[1].status + res.json(water) + }); + + app.get("/water/config", async function (req, res, next) { + const response = await post.postRequest() + const water = response.updateData.zones[1].config + res.json(water) + }); + +} \ No newline at end of file diff --git a/server.js b/server.js index 44490c2..d50124e 100644 --- a/server.js +++ b/server.js @@ -1,45 +1,8 @@ var express = require("express"); var app = express(); -const post = require('./lib/post') -app.get("/heating", async function (req, res, next) { - const response = await post.postRequest() - const heating = response.updateData.zones[0] - res.json(heating) -}); - -app.get("/heating/status", async function (req, res, next) { - const response = await post.postRequest() - const heating = response.updateData.zones[0].status - res.json(heating) -}); - -app.get("/heating/config", async function (req, res, next) { - const response = await post.postRequest() - const heating = response.updateData.zones[0].config - res.json(heating) -}); - -app.get("/water", async function (req, res, next) { - const response = await post.postRequest() - const water = response.updateData.zones[1] - res.json(water) -}); - -app.get("/water/status", async function (req, res, next) { - const response = await post.postRequest() - const water = response.updateData.zones[1].status - res.json(water) -}); - -app.get("/water/config", async function (req, res, next) { - const response = await post.postRequest() - const water = response.updateData.zones[1].config - res.json(water) -}); +require('./routes')(app); app.listen(2020, function () { - - console.log("Server running on port 2020"); }); \ No newline at end of file diff --git a/test.js b/test.js deleted file mode 100644 index ab93be8..0000000 --- a/test.js +++ /dev/null @@ -1,15 +0,0 @@ -var express = require("express"); -var app = express(); - -require('./routes')(app); - -app.listen(2020, function () { - - - console.log("Server running on port 2020"); -}); - - - - -