UNPKG

@opengis/fastify-table

Version:

core-plugins

20 lines (17 loc) 510 B
import { mkdir, writeFile } from 'fs/promises'; import path from 'path'; import grpc from '../grpc.js'; export default async function html2doc({ html, filepath, }) { const result = await grpc.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 }; } }