From 401c5d338b00068f3ad5e5ff2989a4e3ad4bf15e Mon Sep 17 00:00:00 2001 From: Edouard Date: Thu, 12 Mar 2026 09:54:28 +0200 Subject: [PATCH 1/2] Resolving deployment Problems, StartPinger was not a function --- .vscode/settings.json | 6 ++++++ backend/scheduler/pinger.js | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..739fb92 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "workbench.colorCustomizations": { + "minimap.background": "#FF222223", + "scrollbar.shadow": "#FF222223" + } +} \ No newline at end of file diff --git a/backend/scheduler/pinger.js b/backend/scheduler/pinger.js index 8c31788..0c28589 100644 --- a/backend/scheduler/pinger.js +++ b/backend/scheduler/pinger.js @@ -4,21 +4,25 @@ // and pings them. Works even when no user is on the website. const cron = require('node-cron'); -const fetch = require('node-fetch'); +// Removed node-fetch import - using built-in fetch in Node 22 const pool = require('../config/db'); // ── The ping function ────────────────────────────────── // Sends an HTTP GET to a URL and returns the status code const pingURL = async (url) => { try { + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout + const response = await fetch(url, { method: 'GET', - // Timeout after 10 seconds — don't hang forever on dead sites - timeout: 10000 + signal: controller.signal }); + + clearTimeout(timeoutId); return response.status; // e.g. 200, 404, 503 } catch (err) { - // Network error, DNS fail, server completely down + // Network error, DNS fail, server completely down, or timeout console.error(` ✗ Failed to ping ${url}:`, err.message); return null; // null = unreachable } From c5c76e8f474834ff8b002fdcc8ce8d3309d9e41f Mon Sep 17 00:00:00 2001 From: Edouard Date: Thu, 12 Mar 2026 10:29:24 +0200 Subject: [PATCH 2/2] chore: rename frontend to docs for GitHub Pages --- {frontend => docs}/css/style.css | 0 {frontend => docs}/dashboard.html | 0 {frontend => docs}/index.html | 0 {frontend => docs}/js/auth.js | 2 +- {frontend => docs}/js/dashboard.js | 0 {frontend => docs}/login.html | 0 {frontend => docs}/register.html | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename {frontend => docs}/css/style.css (100%) rename {frontend => docs}/dashboard.html (100%) rename {frontend => docs}/index.html (100%) rename {frontend => docs}/js/auth.js (97%) rename {frontend => docs}/js/dashboard.js (100%) rename {frontend => docs}/login.html (100%) rename {frontend => docs}/register.html (100%) diff --git a/frontend/css/style.css b/docs/css/style.css similarity index 100% rename from frontend/css/style.css rename to docs/css/style.css diff --git a/frontend/dashboard.html b/docs/dashboard.html similarity index 100% rename from frontend/dashboard.html rename to docs/dashboard.html diff --git a/frontend/index.html b/docs/index.html similarity index 100% rename from frontend/index.html rename to docs/index.html diff --git a/frontend/js/auth.js b/docs/js/auth.js similarity index 97% rename from frontend/js/auth.js rename to docs/js/auth.js index e057abf..c42599c 100644 --- a/frontend/js/auth.js +++ b/docs/js/auth.js @@ -1,5 +1,5 @@ // js/auth.js -const API = 'http://localhost:5000/api'; // ← change to deployed URL when live +const API = 'https://stayawake.onrender.com/api'; // ← deployed URL function showError(id, msg) { const el = document.getElementById(id); diff --git a/frontend/js/dashboard.js b/docs/js/dashboard.js similarity index 100% rename from frontend/js/dashboard.js rename to docs/js/dashboard.js diff --git a/frontend/login.html b/docs/login.html similarity index 100% rename from frontend/login.html rename to docs/login.html diff --git a/frontend/register.html b/docs/register.html similarity index 100% rename from frontend/register.html rename to docs/register.html