From f89ed0a3a44b7d8dad2b98c9e7a0163bbd93d7ca Mon Sep 17 00:00:00 2001 From: Stefan Ottosson Date: Fri, 12 Aug 2022 18:43:24 +0200 Subject: [PATCH 001/107] feat: added HTTP method option for push monitor --- server/routers/api-router.js | 7 ++- src/pages/EditMonitor.vue | 84 ++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/server/routers/api-router.js b/server/routers/api-router.js index 201efc41f..bba789ac5 100644 --- a/server/routers/api-router.js +++ b/server/routers/api-router.js @@ -31,9 +31,8 @@ router.get("/api/entry-page", async (request, response) => { response.json(result); }); -router.get("/api/push/:pushToken", async (request, response) => { +router.all("/api/push/:pushToken", async (request, response) => { try { - let pushToken = request.params.pushToken; let msg = request.query.msg || "OK"; let ping = request.query.ping || null; @@ -48,6 +47,10 @@ router.get("/api/push/:pushToken", async (request, response) => { throw new Error("Monitor not found or not active."); } + if (monitor.method !== request.method) { + throw new Error("Monitor HTTP method (" + monitor.method + ") does not match request (" + request.method + ")."); + } + const previousHeartbeat = await Monitor.getPreviousHeartbeat(monitor.id); if (monitor.isUpsideDown()) { diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 82859a4ff..d82aa2800 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -398,7 +398,7 @@ -