Hinzufügen der Divera API translation
This commit is contained in:
1 parent
5e46eeff01
commit
6838e7315b
6 files changed
+1147
-3
No files matched your search
+2
-2
@@ -5,6 +5,6 @@ WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install --omit=dev
|
||||
|
||||
COPY status.js .
|
||||
COPY src/* .
|
||||
|
||||
CMD ["node", "status.js"]
|
||||
CMD ["node", "src/main.js"]
|
||||
Generated
+1100
File diff suppressed because it is too large.
Load diff
+2
-1
@@ -17,6 +17,7 @@
|
||||
"dependencies": {
|
||||
"axios": "^1.17.0",
|
||||
"dotenv": "^17.4.2",
|
||||
"express": "^5.2.1",
|
||||
"fs": "^0.0.1-security"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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}`);
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
import "./status.js";
|
||||
import "./alarm_api.js";
|
||||
File renamed without changes.
Reference in new issue
Block a user