import { Handlers, PageProps } from "$fresh/server.ts"; import { query } from "../../db.ts"; import { Page } from "../../components/Page.tsx"; type NoteID = string; export const handler: Handlers = { async POST(request, context) { const content = (await request.formData()).get("content"); if (!content) throw "no content provided"; const result = await query( "insert into note (content) values ($1) returning id", [content], ); if (!result) throw "insert failed"; const { rows: [{ id }] } = result; return await context.render(id); }, }; export default function NotesPage({ data: noteId }: PageProps) { return (

You created a note!

Back to notes View your note
); }