19 lines
623 B
JavaScript
19 lines
623 B
JavaScript
const post = require('../lib/post')
|
|
const common = require('../lib/common')
|
|
const bodyParser = require('body-parser');
|
|
|
|
module.exports = function (app) {
|
|
app.use(bodyParser.urlencoded({ extended: true }));
|
|
|
|
app.post("/water", async function (req, res, next) {
|
|
if (req.query.switch === '1') {
|
|
await post.postRequest('{"zoneId":[1],"setPoint": 255,"durationMinutes": 90}', 'apply_timer')
|
|
} else if (req.query.switch === '0') {
|
|
await post.postRequest('{"zoneId":[1]}', 'cancel_timer')
|
|
} else {
|
|
throw new Error
|
|
}
|
|
res.json(req.query)
|
|
});
|
|
|
|
} |