#!/usr/bin/env -S deno -A
// deno-lint-ignore-file no-unversioned-import
import { Hono } from "jsr:@hono/hono";

const app = new Hono();

const word_list: string[] = [];

app.get("/", (c) => c.text("Ord i URL."));

app.get("/list", (c) => {
  let result = "<html><body><ol>";
  for (const word of word_list) {
    result += "<li> " + word + "</li>";
  }
  result += "</ol></body></html>";
  return c.html(result);
});

app.get("/:word", (c) => {
  const word = c.req.param("word");
  word_list.push(word);
  console.log(word);
  return c.text("> " + word);
});

Deno.serve(app.fetch);
