@opengis/fastify-table
Version:
core-plugins
18 lines (17 loc) • 558 B
JavaScript
import path from "node:path";
import { mkdir, writeFile } from "node:fs/promises";
import grpc from "../grpc.js";
const { html2Doc } = grpc();
export default async function htmlTodoc({ html, filepath, }) {
const result = await html2Doc({ html });
if (result.err)
throw new Error(result.err);
try {
await mkdir(path.dirname(filepath), { recursive: true });
await writeFile(filepath, result.result, "base64");
return { filepath };
}
catch (err) {
return { err: err.toString(), status: 500 };
}
}