import { Handlers, PageProps } from "$fresh/server.ts"; import { query } from "../../db.ts"; import { Page } from "../../components/Page.tsx"; interface Note { id: string; created_at: Date; content: string; } export const handler: Handlers = { async GET(request, context) { console.debug({ request, context }); const result = await query( "select * from note where id = $1 order by created_at desc", [context.params["id"]], ); if (result == null) throw "unable to fetch from database"; const [note] = result.rows as Note[]; return await context.render(note); }, }; export default function NotesPage( { data: { id, created_at, content } }: PageProps, ) { return (

Note {id} created at {created_at.toLocaleString()}

{content}
); }