import { MainLayout } from "@components/layouts/main.tsx";
import { PageProps } from "fresh";
import { getCacheInfo } from "@lib/cache.ts";
import { define } from "../../../utils.ts";

export const handler = define.handlers({
  GET() {
    return { data: { cacheInfo: getCacheInfo() } };
  },
});

export default function Greet(
  props: PageProps<
    { cacheInfo: ReturnType<typeof getCacheInfo> }
  >,
) {
  const { cacheInfo } = props.data;
  return (
    <MainLayout
      url={props.url}
      title="Recipes"
      context={{ type: "recipes" }}
    >
      <code>
        <pre class="text-white">
          {JSON.stringify(cacheInfo, null, 2)}
        </pre>
      </code>
    </MainLayout>
  );
}
