Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/** @jsxImportSource npm:hono@3/jsx */
import valTownBadgeMiddleware from "https://esm.town/v/jxnblk/valTownBadgeMiddleware?v=10";
import { Hono } from "npm:hono";
const app = new Hono();
export default valTownBadgeMiddleware(app.fetch, import.meta.url);
app.get("/", (c) => {
return c.html(
<html>
<head>
<title>DNS Lookup Tool</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="icon" href="https://fav.farm/πŸ”Ž" />
</head>
<body class="p-4">
<h1 class="text-3xl font-bold underline">DNS Lookup Tool</h1>
<form method="get" action="/dns-lookup" class="mt-4">
<label class="block mb-2">
Domain name:
<input type="text" name="domain" class="border p-2 w-full" />
</label>
<button type="submit" class="bg-blue-500 text-white py-2 px-4 rounded">
Check DNS
</button>
</form>
</body>
</html>,
);
});
app.get("/dns-lookup", async (c) => {
const domain = c.req.query("domain");
const results = await Promise.all([
"A",
"AAAA",
"MX",
"NS",
"CNAME",
"SOA",
"TXT",
].map(async record => [record, await Deno.resolveDns(domain, record).catch(e => e.toString())]));
return c.html(
<html>
<head>
<title>DNS Lookup Result</title>
<link rel="icon" href="https://fav.farm/πŸ”Ž" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-4">
<h1 class="text-3xl font-bold underline">DNS Lookup Results for {domain}</h1>
{results.map(([recordType, entries]) => (
<div class="my-4">
<h2 class="text-xl fold-bold">{recordType}</h2>
<ul>
{entries.map ? entries.map(entry => <li>{entry}</li>) : entries}
</ul>
</div>
))}
<div class="mt-4">
<a
href="/"
class="bg-blue-500 text-white py
-2 px-4 rounded"
>
Back
</a>
</div>
</body>
</html>,
);
});
stevekrouse-dns.web.val.run
June 20, 2024