import { Handlers, PageProps } from "$fresh/server.ts"; import { query } from "../db.ts"; 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 notes"); if (result == null) throw "unable to fetch from database"; const notes = result.rows as Note[]; console.debug(notes); return await context.render(notes); }, }; export default function Page({ data }: PageProps) { return (

List of Notes

Create a note:

        {JSON.stringify(data, null, 2)}
      
); }