Hinzufügen der Divera API translation
This commit is contained in:
@@ -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"]
|
||||
1100
package-lock.json
generated
Normal file
1100
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@
|
||||
"dependencies": {
|
||||
"axios": "^1.17.0",
|
||||
"dotenv": "^17.4.2",
|
||||
"express": "^5.2.1",
|
||||
"fs": "^0.0.1-security"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
src/alarm_api.js
Normal file
41
src/alarm_api.js
Normal 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
2
src/main.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import "./status.js";
|
||||
import "./alarm_api.js";
|
||||
Reference in New Issue
Block a user