-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
43 lines (39 loc) · 1.03 KB
/
index.ts
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
34
35
36
37
38
39
40
41
42
43
const port = parseInt(process.env.PORT) || 3000
Bun.serve({
fetch(req) {
return new Response(`
<html>
<head>
<title>ajcwebdev-bun</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
</head>
<body>
<h1>Hello from ajcwebdev on Bun</h1>
<p>Now with proper HTML structure, CSS, and error handling.</p>
<h2>Heading 2</h2>
<ul>
<li>An</li>
<li>unordered</li>
<li>list</li>
</ul>
<h3>Heading 3</h3>
<ol>
<li>An</li>
<li>ordered</li>
<li>list</li>
</ol>
</body>
</html>`,
{ headers: { 'content-type': 'text/html' } }
)
},
error(error: Error) {
return new Response(
"Error: \n" + error.toString(),
{ status: 500 }
)
},
port: port
})
console.log(`Hello via Bun on ${port}!`)