added edit endpoint

This commit is contained in:
Dawid Kubicki 2019-01-19 00:44:21 +01:00
parent 1c44bca071
commit fe001c3292

View File

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