Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"workbench.colorCustomizations": {
"minimap.background": "#FF222223",
"scrollbar.shadow": "#FF222223"
}
}
12 changes: 8 additions & 4 deletions backend/scheduler/pinger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/js/auth.js → docs/js/auth.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading