1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { email } from "https://esm.town/v/std/email?v=11";
import { fetch } from "https://esm.town/v/std/fetch";
export default async () => {
const URL = "https://tsevdos.me";
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) {
console.log(`Website up (${URL})`);
} else {
const subject = `Website down (${URL})`;
const text = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
console.log(subject);
console.log(text);
await email({ subject, text });
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { email } from "https://esm.town/v/std/email?v=11";
import { fetch } from "https://esm.town/v/std/fetch";
export default async () => {
const URL = "https://bedrockcap.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) {
console.log(`Website up (${URL})`);
} else {
const subject = `Website down (${URL})`;
const text = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
console.log(subject);
console.log(text);
await email({ subject, text });
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { email } from "https://esm.town/v/std/email?v=11";
export default 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) {
console.log(`Website up (${URL})`);
} else {
const subject = `Website down (${URL})`;
const text = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
console.log(subject);
console.log(text);
await email({ subject, text });
}
};

Pass a URL to ping a website and see if response is a 200. If it isn't, you get an email with the error response received.

Tip: Make a new, separate cron val to call this isMyWebsiteDown() periodically to check the website's health every 15 minutes or so.
Your separate cron val's code will look something like this:

//Import this val
import isMyWebsiteDown from "https://esm.town/v/dvsj/isMyWebsiteDown";

//Add all the websites you want to check
isMyWebsiteDown(`https://dvsj.in`);
isMyWebsiteDown(`https://blog.dvsj.in`);

export default {};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { email } from "https://esm.town/v/std/email?v=11";
import { fetch } from "https://esm.town/v/std/fetch";
export default async (URL) => {
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) {
console.log(`Website up (${URL})`);
} else {
const subject = `Website down (${URL})`;
const text = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
console.log(subject);
console.log(text);
await email({ subject, text });
}
};
Runs every 1 hrs
Fork
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { email } from "https://esm.town/v/std/email";
import { fetch } from "https://esm.town/v/std/fetch";
export const isMyWebsiteDown = async () => {
const URL = "https://www.anotherplanet.io";
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 text = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
await email({ subject, text });
}
};

Emails me if my personal website is down. (If you fork this, it'll email you, since you'll be the owner of the new fork.)

Runs every 15 min
Fork
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { email } from "https://esm.town/v/std/email";
import { fetch } from "https://esm.town/v/std/fetch";
export const isMyWebsiteDown = async () => {
const URL = "https://devonzuegel.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 text = `At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
email({ subject, text });
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { fetch } from "https://esm.town/v/std/fetch";
export const isMyWebsiteDown = async () => {
const URL = "https://suryad.com";
const [date, time] = new Date().toISOString().split("T");
let ok = true;
let reason: string;
console.log("hi there");
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) {
console.log("not good");
const subject = `Website down (${URL})`;
const body =
`At ${date} ${time} (UTC), ${URL} was down (reason: ${reason}).`;
return body;
}
else {
console.log("its good");
const body = `At ${date} ${time} (UTC), ${URL} is up.`;
return body;
}
};
// Forked from @healeycodes.isMyWebsiteDown
1
Next