firebase-uptime
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -1,8 +0,6 @@ | ||
const admin = require('firebase-admin'); | ||
const functions = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
const db = getFirestore(); | ||
const apiStatusCleanUp = async () => { | ||
const apiStatusRef = db.collection('ApiStatus').doc() | ||
const apiStatusRef = admin.firestore().collection('ApiStatus').doc() | ||
const apiStatusSnapshot = await apiStatusRef.get() | ||
@@ -14,3 +12,3 @@ if (apiStatusSnapshot.empty) { | ||
apiStatusSnapshot.forEach((doc: any ) => { | ||
const statusRef = db.collection('ApiStatus').doc(doc.id).collection("status").where('timestamp', '<', new Date(Date.now() - 1000 * 60 * 60 * 24 * 30).toISOString()) | ||
const statusRef = admin.firestore().collection('ApiStatus').doc(doc.id).collection("status").where('timestamp', '<', new Date(Date.now() - 1000 * 60 * 60 * 24 * 30).toISOString()) | ||
const statusSnapshot = statusRef.get() | ||
@@ -17,0 +15,0 @@ if (statusSnapshot.empty) { |
@@ -1,8 +0,6 @@ | ||
const admin = require('firebase-admin'); | ||
const functions = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
const db = getFirestore(); | ||
const currentStatus = async (api: string) => { | ||
const apiStatusRef = db.collection('ApiStatus').doc(api).collection("status").desc('timestamp').limit(1) | ||
const apiStatusRef = admin.firestore().collection('ApiStatus').doc(api).collection("status").desc('timestamp').limit(1) | ||
const apiStatusSnapshot = await apiStatusRef.get() | ||
@@ -9,0 +7,0 @@ if (apiStatusSnapshot.empty) { |
@@ -13,7 +13,6 @@ "use strict"; | ||
exports.reportingCleanup = void 0; | ||
const admin = require('firebase-admin'); | ||
const functions = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
const db = getFirestore(); | ||
const apiStatusCleanUp = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const apiStatusRef = db.collection('ApiStatus').doc(); | ||
const apiStatusRef = admin.firestore().collection('ApiStatus').doc(); | ||
const apiStatusSnapshot = yield apiStatusRef.get(); | ||
@@ -25,3 +24,3 @@ if (apiStatusSnapshot.empty) { | ||
apiStatusSnapshot.forEach((doc) => { | ||
const statusRef = db.collection('ApiStatus').doc(doc.id).collection("status").where('timestamp', '<', new Date(Date.now() - 1000 * 60 * 60 * 24 * 30).toISOString()); | ||
const statusRef = admin.firestore().collection('ApiStatus').doc(doc.id).collection("status").where('timestamp', '<', new Date(Date.now() - 1000 * 60 * 60 * 24 * 30).toISOString()); | ||
const statusSnapshot = statusRef.get(); | ||
@@ -28,0 +27,0 @@ if (statusSnapshot.empty) { |
@@ -13,7 +13,6 @@ "use strict"; | ||
exports.apiCurrentStatus = void 0; | ||
const admin = require('firebase-admin'); | ||
const functions = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
const db = getFirestore(); | ||
const currentStatus = (api) => __awaiter(void 0, void 0, void 0, function* () { | ||
const apiStatusRef = db.collection('ApiStatus').doc(api).collection("status").desc('timestamp').limit(1); | ||
const apiStatusRef = admin.firestore().collection('ApiStatus').doc(api).collection("status").desc('timestamp').limit(1); | ||
const apiStatusSnapshot = yield apiStatusRef.get(); | ||
@@ -20,0 +19,0 @@ if (apiStatusSnapshot.empty) { |
@@ -13,9 +13,8 @@ "use strict"; | ||
exports.apiReports = void 0; | ||
const admin = require('firebase-admin'); | ||
const functions = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
const db = getFirestore(); | ||
const axios = require('axios'); | ||
const getApiData = () => __awaiter(void 0, void 0, void 0, function* () { | ||
let apiList = []; | ||
const apiRef = db.collection('ApiCollection'); | ||
const apiRef = admin.firestore().collection('ApiCollection'); | ||
const apiSnapshot = yield apiRef.get(); | ||
@@ -37,3 +36,3 @@ if (apiSnapshot.empty) { | ||
functions.logger.log(res.status); | ||
db.collection('ApiStatus').doc(item.label).collection("status").add({ | ||
admin.firestore().collection('ApiStatus').doc(item.label).collection("status").add({ | ||
status: res.status, | ||
@@ -40,0 +39,0 @@ timestamp: new Date(Date.now()).toISOString(), |
@@ -13,9 +13,7 @@ "use strict"; | ||
exports.apiUptimeStatus = void 0; | ||
const admin = require('firebase-admin'); | ||
const { functions } = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
; | ||
const db = getFirestore(); | ||
const UptimeStatusHistory = (api, days) => __awaiter(void 0, void 0, void 0, function* () { | ||
let apiStatusArr = []; | ||
const apiStatusRef = db.collection('ApiStatus').doc(api).collection("status").where('timestamp', '>', new Date(Date.now() - 1000 * 60 * 60 * 24 * days).toISOString()); | ||
const apiStatusRef = admin.firestore().collection('ApiStatus').doc(api).collection("status").where('timestamp', '>', new Date(Date.now() - 1000 * 60 * 60 * 24 * days).toISOString()); | ||
const apiStatusSnapshot = yield apiStatusRef.get(); | ||
@@ -22,0 +20,0 @@ if (apiStatusSnapshot.empty) { |
{ | ||
"name": "firebase-uptime", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Monitoring tool for external APIs used in your project.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,6 +0,4 @@ | ||
const admin = require('firebase-admin'); | ||
const functions = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore'); | ||
const db = getFirestore(); | ||
const axios = require('axios'); | ||
@@ -10,3 +8,3 @@ | ||
let apiList: any[] = [] | ||
const apiRef = db.collection('ApiCollection') | ||
const apiRef = admin.firestore().collection('ApiCollection') | ||
const apiSnapshot = await apiRef.get() | ||
@@ -32,3 +30,3 @@ if (apiSnapshot.empty) { | ||
functions.logger.log(res.status) | ||
db.collection('ApiStatus').doc(item.label).collection("status").add({ | ||
admin.firestore().collection('ApiStatus').doc(item.label).collection("status").add({ | ||
status: res.status, | ||
@@ -35,0 +33,0 @@ timestamp: new Date(Date.now()).toISOString(), |
@@ -0,8 +1,7 @@ | ||
const admin = require('firebase-admin'); | ||
const { functions } = require('firebase-functions'); | ||
const { getFirestore } = require('firebase-admin/firestore');; | ||
const db = getFirestore(); | ||
const UptimeStatusHistory = async ( api: string, days: number) => { | ||
let apiStatusArr: any[] = [] | ||
const apiStatusRef = db.collection('ApiStatus').doc(api).collection("status").where('timestamp', '>', new Date(Date.now() - 1000 * 60 * 60 * 24 * days).toISOString()) | ||
const apiStatusRef = admin.firestore().collection('ApiStatus').doc(api).collection("status").where('timestamp', '>', new Date(Date.now() - 1000 * 60 * 60 * 24 * days).toISOString()) | ||
const apiStatusSnapshot = await apiStatusRef.get() | ||
@@ -9,0 +8,0 @@ if (apiStatusSnapshot.empty) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
29556
314