From fe001c329208c825b4ab204c5120a5e553b556a8 Mon Sep 17 00:00:00 2001 From: Dawid Kubicki Date: Sat, 19 Jan 2019 00:44:21 +0100 Subject: [PATCH] added edit endpoint --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6cbfd41..42c0518 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ const save_data = async time => { let interval = setInterval(() => { save_data(Date.now()); -}, 5000); +}, 15000); const getScript = url => { return new Promise((resolve, reject) => { @@ -102,7 +102,7 @@ app.get("/start", (req, res) => { if (interval === null) { interval = setInterval(() => { save_data(Date.now()); - }, 5000); + }, 15000); res.json({ message: "Zaczalem dzialac :>" }); } else { @@ -132,6 +132,14 @@ app.delete("/device/:ip", async (req, res) => { res.json({ Sukces: "Usuwa OK" }); }); +app.put("/device/:id", async (req, res) => { + const newDevice = await deviceSchema.findByIdAndUpdate( + req.params.id, + req.body + ); + res.json(newDevice); +}); + app.listen(port, () => console.log(`Chillroom server nasluchuje na porcie ${port}!`) );