Implement feature

This commit is contained in:
2023-09-16 13:12:29 +02:00
parent 02bc520a7f
commit d94a303ee2
5 changed files with 275 additions and 3931 deletions
+22
View File
@@ -0,0 +1,22 @@
import axios from "axios";
/**
* Sends a heartbeat to the provided URL
* @param url The URL to send the heartbeat to
* @param debug Whether to log debug information
* @private
*/
export default async function sendHeartbeat(url: string, debug: boolean = false) {
const useUrl = new URL(url);
try {
const response = await axios.get(`${useUrl.origin}/${useUrl.pathname}?status=up&msg=OK`);
if (debug)
console.log(
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText} - ${
response.data
}`
);
} catch (error) {
console.error(`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${error}`);
}
}