Hinzufügen der Divera API translation

This commit is contained in:
2026-06-09 19:09:39 +02:00
parent 5e46eeff01
commit 6838e7315b
6 changed files with 1147 additions and 3 deletions

View File

@@ -5,6 +5,6 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install --omit=dev RUN npm install --omit=dev
COPY status.js . COPY src/* .
CMD ["node", "status.js"] CMD ["node", "src/main.js"]

1100
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,7 @@
"dependencies": { "dependencies": {
"axios": "^1.17.0", "axios": "^1.17.0",
"dotenv": "^17.4.2", "dotenv": "^17.4.2",
"express": "^5.2.1",
"fs": "^0.0.1-security" "fs": "^0.0.1-security"
} }
} }

41
src/alarm_api.js Normal file
View File

@@ -0,0 +1,41 @@
import express from "express";
import axios from "axios";
const app = express();
const port = 3000;
app.get("/get_last_alarm/:accesskey", async (req, res) => {
const accessKey = req.params.accesskey;
if (!accessKey) {
return res.status(400).send("Access key is required");
}
try {
const response = await axios.get(process.env.BASE_URL + "/v2/alarms?accesskey=" + accessKey);
res.json(response.data.data.items[response.data.data.sorting[0]]);
} catch (error) {
console.error("Error fetching alarm data:", error);
res.status(500).send("Error fetching alarm data");
}
});
app.get("/get_last_alarm_by_id/:accesskey", async (req, res) => {
const accessKey = req.params.accesskey;
if (!accessKey) {
return res.status(400).send("Access key is required");
}
try {
const response = await axios.get(process.env.BASE_URL + "/v2/alarms?accesskey=" + accessKey);
res.json(response.data.data.items[response.data.data.sorting[0]].foreign_id);
} catch (error) {
console.error("Error fetching alarm data:", error);
res.status(500).send("Error fetching alarm data");
}
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});

2
src/main.js Normal file
View File

@@ -0,0 +1,2 @@
import "./status.js";
import "./alarm_api.js";