diff --git a/index.js b/index.js index decdb7d..e2537fa 100644 --- a/index.js +++ b/index.js @@ -94,6 +94,18 @@ app.get("/stop", (req, res) => { res.json({ message: "Przestalem dzialac :<" }); }); +app.get("/status/:id", async (req, res) => { + const data = await statusSchema + .findOne({ + device: mongoose.Types.ObjectId(req.params.id) + }) + .select("status"); + const status = data.status.sort((a, b) => { + return b.time - a.time; + }); + res.json(status); +}); + app.get("/start", (req, res) => { if (interval === null) { interval = setInterval(() => {