Version 1.0.0 #1
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@astrogd/eu.astrogd.uptime-kuma-push-monitor",
|
"name": "@astrogd/eu.astrogd.uptime-kuma-push-monitor",
|
||||||
"version": "1.0.0-dev.6",
|
"version": "1.0.0-dev.7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@astrogd/eu.astrogd.uptime-kuma-push-monitor",
|
"name": "@astrogd/eu.astrogd.uptime-kuma-push-monitor",
|
||||||
"version": "1.0.0-dev.6",
|
"version": "1.0.0-dev.7",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.5.0"
|
"axios": "^1.5.0"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@astrogd/eu.astrogd.uptime-kuma-push-monitor",
|
"name": "@astrogd/eu.astrogd.uptime-kuma-push-monitor",
|
||||||
"version": "1.0.0-dev.6",
|
"version": "1.0.0-dev.7",
|
||||||
"description": "Handles uptime kuma push monitor uptime requests",
|
"description": "Handles uptime kuma push monitor uptime requests",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/types/",
|
"types": "dist/types/",
|
||||||
|
@ -8,8 +8,9 @@ import axios from "axios";
|
|||||||
*/
|
*/
|
||||||
export async function sendHeartbeat(url: string, performance?: number, debug: boolean = false) {
|
export async function sendHeartbeat(url: string, performance?: number, debug: boolean = false) {
|
||||||
const useUrl = new URL(url);
|
const useUrl = new URL(url);
|
||||||
|
const parsedURL = `${useUrl.origin}/${useUrl.pathname}?status=up&msg=OK${performance ? `&ping=${performance}` : ""}`;
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${useUrl.origin}/${useUrl.pathname}?status=up&msg=OK${performance ? `&ping=${performance}` : ""}`);
|
const response = await axios.get(parsedURL);
|
||||||
if (debug)
|
if (debug)
|
||||||
console.log(
|
console.log(
|
||||||
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText}`
|
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText}`
|
||||||
@ -27,8 +28,9 @@ export async function sendHeartbeat(url: string, performance?: number, debug: bo
|
|||||||
*/
|
*/
|
||||||
export async function sendDownNotification(url: string, msg: string = "Error",debug: boolean = false) {
|
export async function sendDownNotification(url: string, msg: string = "Error",debug: boolean = false) {
|
||||||
const useUrl = new URL(url);
|
const useUrl = new URL(url);
|
||||||
|
const parsedURL = `${useUrl.origin}/${useUrl.pathname}?status=DOWN&msg=${msg}`;
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${useUrl.origin}/${useUrl.pathname}?status=DOWN&msg=${msg}`);
|
const response = await axios.get(parsedURL);
|
||||||
if (debug)
|
if (debug)
|
||||||
console.log(
|
console.log(
|
||||||
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText}`
|
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText}`
|
||||||
|
Loading…
Reference in New Issue
Block a user