added edit endpoint
This commit is contained in:
parent
1c44bca071
commit
fe001c3292
12
index.js
12
index.js
@ -41,7 +41,7 @@ const save_data = async time => {
|
|||||||
|
|
||||||
let interval = setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
save_data(Date.now());
|
save_data(Date.now());
|
||||||
}, 5000);
|
}, 15000);
|
||||||
|
|
||||||
const getScript = url => {
|
const getScript = url => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -102,7 +102,7 @@ app.get("/start", (req, res) => {
|
|||||||
if (interval === null) {
|
if (interval === null) {
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
save_data(Date.now());
|
save_data(Date.now());
|
||||||
}, 5000);
|
}, 15000);
|
||||||
|
|
||||||
res.json({ message: "Zaczalem dzialac :>" });
|
res.json({ message: "Zaczalem dzialac :>" });
|
||||||
} else {
|
} else {
|
||||||
@ -132,6 +132,14 @@ app.delete("/device/:ip", async (req, res) => {
|
|||||||
res.json({ Sukces: "Usuwa OK" });
|
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, () =>
|
app.listen(port, () =>
|
||||||
console.log(`Chillroom server nasluchuje na porcie ${port}!`)
|
console.log(`Chillroom server nasluchuje na porcie ${port}!`)
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user