Łatki bezpieczeństwa, dodana nowa sceneria do danych

This commit is contained in:
2020-08-15 13:23:02 +02:00
parent 9e3f02bfe2
commit 00ab5e9713
9 changed files with 180 additions and 138 deletions
+1 -1
View File
@@ -14,11 +14,11 @@
},
"main": "lib/index.js",
"dependencies": {
"axios": "^0.19.2",
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.1"
},
"devDependencies": {
"axios": "^0.19.2",
"firebase-functions-test": "^0.2.0",
"tslint": "^5.12.0",
"typescript": "^3.8.0"
+18 -10
View File
@@ -7,14 +7,22 @@ const db = admin.firestore();
import axios from "axios";
exports.scheduledUpdate = functions.pubsub
.schedule("5 * * * *")
.schedule("*/5 * * * *")
.onRun(async (context) => {
const stationData: {
let stationData: {
stationName: string;
dispatcherName: string;
}[] = await (
await axios.get("https://api.td2.info.pl:9640/?method=getStationsOnline")
).data.message;
}[];
try {
stationData = await (
await axios.get(
"https://api.td2.info.pl:9640/?method=getStationsOnline"
)
).data.message;
} catch (error) {
return;
}
const historyRef = db.collection("history");
@@ -28,11 +36,11 @@ exports.scheduledUpdate = functions.pubsub
currentDispatcherName: station.dispatcherName,
});
docRef.collection("dispatcherHistory").add({
dispatcherName: station.dispatcherName,
occupiedFrom: Date.now(),
occupiedTo: 0,
});
// docRef.collection("dispatcherHistory").add({
// dispatcherName: station.dispatcherName,
// occupiedFrom: Date.now(),
// occupiedTo: 0,
// });
return;
}