Markit SDK + Hono Integration Patterns

Markit SDK (markit-ai) Integration Patterns

Constructor: new Markit({ describe, transcribe }) — AI functions set at construction time, NOT per-call. markit.convert(buffer, { extension, filename }) returns { markdown: string; title?: string }.

mupdf: Ships as pre-built WASM — no build-essential or native compilation needed in Docker. Common misconception that it requires native bindings.

Hono SSE: Use streamSSE from hono/streaming. Track clients via Set. stream.writeSSE({ event, data }) for sending. @hono/node-server REQUIRED alongside hono to listen on a port.

Hono multipart: c.req.parseBody({ all: true }) returns File objects. file.arrayBuffer() buffers in memory — no streaming alternative. Bound via bodyLimit() middleware.

Quality audit patterns (18 issues found across 4 parallel agents):

  • Unhandled promise rejection in async IIFE error handlers — always wrap broadcast calls
  • File descriptor leak: openSync/closeSync needs try/finally
  • Content-Disposition header injection: sanitize filenames for HTTP headers
  • serve() return must be captured for server.close() in graceful shutdown
  • Frontend regressions: always compare new SPA against original for feature parity