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 } 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