split files

This commit is contained in:
Karl 2020-05-07 22:12:45 +01:00
parent ab80e634d3
commit 20631f0440
4 changed files with 37 additions and 54 deletions

View File

@ -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)
});
}

22
routes/water.js Normal file
View File

@ -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)
});
}

View File

@ -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");
});

15
test.js
View File

@ -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");
});