116 try {
117 // Replace with your actual Val Town endpoint URL
118 const response = await fetch(window.location.href, {
119 method: 'POST',
120 headers: {
25});
26
27// Export the fetch handler for Val Town
28export default app.fetch;
34 const lineEnd = lineMatch[2] ? parseInt(lineMatch[2], 10) : lineStart;
35
36 // Fetch the code
37 const valTownUrl = `https://esm.town/v/${username}/${project}/${filepath}`;
38 const codeResponse = await fetch(valTownUrl);
39
40 if (!codeResponse.ok) {
41 return new Response(`Failed to fetch code: ${codeResponse.statusText}`, { status: 500 });
42 }
43
89 const fontUrl =
90 "https://cdn.jsdelivr.net/npm/@fontsource/ibm-plex-mono@5.0.8/files/ibm-plex-mono-latin-700-normal.woff";
91 const fontResponse = await fetch(fontUrl);
92 return await fontResponse.arrayBuffer();
93}
1async function fetchHackerNews() {
2 try {
3 const response = await fetch("https://news.ycombinator.com/");
4
5 if (!response.ok) {
10 console.log(html);
11 } catch (error) {
12 console.error("Failed to fetch Hacker News:", error);
13 }
14}
15
16export default async function(req: Request): Promise<Response> {
17 const hackerNews = await fetchHackerNews();
18 // return Response.json({ ok: true })
19 return Response.json({ ok: true, hackerNews });
7
8 try {
9 // Using node-fetch to make a request to the domain
10 // This is a simple way to access the certificate info
11 const controller = new AbortController();
12 const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
13
14 const response = await fetch(`https://${domain}`, {
15 method: "HEAD", // We only need the headers
16 signal: controller.signal,
19 clearTimeout(timeoutId);
20
21 // Unfortunately, the fetch API doesn't give us direct access to the certificate
22 // So we need to use the tls module in Node.js or Deno's TLS APIs
23
44});
45
46export default app.fetch;
5 const host = "www.cdatacloud.net";
6
7 const analyzeRes = await fetch(`https://api.ssllabs.com/api/v3/analyze?host=${host}`);
8 const analyzeJson = await analyzeRes.json();
9
17 }
18
19 const endpointRes = await fetch(
20 `https://api.ssllabs.com/api/v3/getEndpointData?host=${host}&ip=${endpoint.ipAddress}`,
21 );
109
110 try {
111 const response = await fetch('/expand', {
112 method: 'POST',
113 headers: {
199
200 try {
201 const response = await fetch('/api/expand', {
202 method: 'POST',
203 headers: {