import { MarkpdfClient } from "@markpdf/bun";
const client = new MarkpdfClient({ apiKey: Bun.env.MARKPDF_API_KEY! });
Bun.serve({
port: 3000,
async fetch(req) {
if (req.method !== "POST") return new Response("Method not allowed", { status: 405 });
const form = await req.formData();
const file = form.get("file") as File;
const markdown = await client.convertBytes(await file.arrayBuffer(), file.name, {
mode: "fast",
});
return new Response(markdown, { headers: { "content-type": "text/markdown" } });
},
});