src/index.ts 1.5 K raw
1
import { Hono } from "hono";
2
import { getSystemStats, formatStats } from "./stats";
3
4
const app = new Hono();
5
6
app.get("/", async (c) => {
7
	const txt = await Bun.file("./src/site.txt").text();
8
	const stats = await getSystemStats();
9
	const statsBox = formatStats(stats);
10
	const fullContent = `${txt}\n\n${statsBox}\n`;
11
	const userAgent = c.req.header("User-Agent") || "";
12
	const isCrawler = /bot/i.test(userAgent);
13
14
	if (isCrawler) {
15
		return c.html(`<!DOCTYPE html>
16
<html>
17
<head>
18
<title>Polybius Software LLC</title>
19
<meta name="description" content="Building tools for a better internet">
20
<meta property="og:url" content="https://polybiussoftware.llc">
21
<meta property="og:type" content="website">
22
<meta property="og:title" content="Polybius Software LLC">
23
<meta property="og:description" content="Building tools for a better internet">
24
<meta property="og:image" content="/og.png">
25
26
<meta name="twitter:card" content="summary_large_image">
27
<meta property="twitter:domain" content="polybiussoftware.llc">
28
<meta property="twitter:url" content="https://polybiussoftware.llc">
29
<meta name="twitter:title" content="Polybius Software LLC">
30
<meta name="twitter:description" content="Building tools for a better internet">
31
<meta name="twitter:image" content="/og.png">
32
</head>
33
<body>
34
${fullContent}
35
</body>
36
</html>
37
`);
38
	}
39
40
	return c.text(fullContent);
41
});
42
43
app.get("/og.png", async (c) => {
44
	const image = Bun.file("./src/og.png");
45
	return c.body(image.stream(), {
46
		headers: {
47
			"Content-Type": "image/png",
48
		},
49
	});
50
});
51
52
export default {
53
	port: 4321,
54
	fetch: app.fetch,
55
};