Readme

Uptime Checker & Status Page

Installation

  1. Fork this val
  2. Edit the list of URLs to what you want to check
  3. For the status page, fork this val: @stevekrouse/status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { fetch } from "https://esm.town/v/std/fetch";
export const isMyWebsiteDown = async () => {
const URL = "https://healeycodes.com";
const [date, time] = new Date().toISOString().split("T");
let ok = true;
let reason: string;
try {
const res = await fetch(URL);
if (res.status !== 200) {
reason = `(status code: ${res.status})`;
ok = false;
}
} catch (e) {
reason = `couldn't fetch: ${e}`;
ok = false;
}
if (!ok) {
const subject = `Website down (${URL})`;
const body = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
console.email(body, subject);
}
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v4
June 11, 2024