import { Handlers, PageProps } from "$fresh/server.ts"; import { listNotes } from "@/db/mod.ts"; import { Page } from "@/components/Page.tsx"; import { type Note } from "@/types.ts"; export const handler: Handlers = { async GET(_request, context) { const result = await listNotes(); if (!result) throw "unable to fetch from database"; return await context.render(result.rows); }, }; export default function NotesPage({ data: notes }: PageProps) { return (

List of Notes

Create a note:

{notes.map(({ id, content, createdAt }) => (
Note {id}{" "} created at {createdAt.toLocaleString()}
{content}
))}
); }