node-js-serwer pull dawid #1

Merged
s412146 merged 1 commits from develop into master 2019-01-14 11:09:49 +01:00

View File

@ -36,14 +36,6 @@ const save_data = async time => {
}
} catch (error) {
console.log("ERROR z CATCHA => " + error);
// const item = new dbSchema({
// ip,
// status: "Urządzenie przestało działać - prawdopodobnie brak zasilania"
// });
// item
// .save()
// .then()
// .catch();
}
};
@ -77,7 +69,7 @@ const getScript = url => {
});
})
.on("error", err => {
reject(err);
resolve('{"Sensors": [{ "Switch": 2 }]}');
});
});
};
@ -133,10 +125,10 @@ app.post("/device", async (req, res) => {
res.json({ Sukces: "Dodaje OK" });
});
app.delete("/device/:id", async (req, res) => {
app.delete("/device/:ip", async (req, res) => {
console.log(req.body);
const newDevice = await deviceSchema.findByIdAndRemove(req.params.id);
await statusSchema.findOneAndRemove({ device: req.params.id });
const newDevice = await deviceSchema.findOneAndRemove({ ip: req.params.ip });
await statusSchema.findOneAndRemove({ device: newDevice });
res.json({ Sukces: "Usuwa OK" });
});