import { MainLayout } from "@components/layouts/main.tsx"; import { Handlers, PageProps } from "$fresh/server.ts"; import { AccessDeniedError } from "@lib/errors.ts"; import { getLogs, Log } from "@lib/logs.ts"; import { formatDate } from "@lib/string.ts"; import { renderMarkdown } from "@lib/documents.ts"; const renderLog = (t: unknown) => renderMarkdown(`\`\`\`js ${typeof t === "string" ? t : JSON.stringify(t).trim()} \`\`\``); export const handler: Handlers = { async GET(_, ctx) { const logs = await getLogs(); if (!("session" in ctx.state)) { throw new AccessDeniedError(); } return ctx.render({ logs: logs.map((l) => { return { ...l, html: l.args.map(renderLog).join("\n"), }; }), }); }, }; function LogLine( { log }: { log: Log; }, ) { return (
{log.html}