time calculation logic added
This commit is contained in:
parent
cb482bce13
commit
554b17a589
12
index.js
12
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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user