// Custom transport that caps body size — should NOT trigger.
export async function readRequestBody(req: any): Promise<string> {
  const maxMessageSize = 1024 * 1024;
  const contentLength = Number(req.headers["content-length"] ?? 0);
  if (contentLength > maxMessageSize) {
    throw new Error("payload too large");
  }
  let body = "";
  let total = 0;
  for await (const chunk of req) {
    total += chunk.length;
    if (total > maxMessageSize) throw new Error("body exceeds cap");
    body += chunk.toString("utf-8");
  }
  return body;
}
