Move to Deno+Bunny.net, add a way to test webring locally.

This commit is contained in:
DS 2025-02-23 23:47:07 -08:00
parent 9f66f0b37b
commit 8670aa3412
33 changed files with 599 additions and 3360 deletions

50
src/main.ts Normal file
View file

@ -0,0 +1,50 @@
import { generateIndex } from './render_templates.ts';
import { redirectNext } from './next.ts';
import { redirectPrevious } from './previous.ts';
import { redirectRandom } from './random.ts';
export function handleFunctions(req: Request) {
const url = new URL(req.url);
switch (url.pathname) {
case '/next': {
return redirectNext(req);
}
case '/previous': {
return redirectPrevious(req);
}
case '/random': {
return redirectRandom(req);
}
}
return undefined;
}
if (import.meta.main) {
const index = generateIndex();
Deno.serve({ hostname: '127.0.0.1' }, (req) => {
const funcResp = handleFunctions(req);
if (funcResp !== undefined) {
return funcResp;
}
const url = new URL(req.url);
if (url.pathname === '/') {
return new Response(index, {
status: 200,
headers: {
'content-type': 'text/html',
},
});
}
return new Response(null, {
status: 404,
});
});
}