import { PageProps } from "$fresh/server.ts"; import { json_response } from "utils"; import { get_message } from "db"; export async function handler( req: Request, props: PageProps ): Promise { if (req.method == "GET") { return await get(props); } else { return new Response(JSON.stringify({ err: "expected a PUT" })); } } async function get(props: PageProps): Promise { const got = await get_message(props.params.id); if (!got) { return json_response({ err: "not found" }, { status: 404 }); } else { return json_response(got, { status: 300 }); } }