Back

Version 0

8/21/2023
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);
}
};
// Forked from @healeycodes.isMyWebsiteDown
Updated: October 23, 2023