import f from "fastify"; import fs from "node:fs"; import path from "node:path"; import { DEFAULT_CONFIG, hydrate, hydrate2Html, rem2Html } from "./index.js"; import { /// @type {Workspace} workspace, } from "../test.js"; const fastify = f({ // Set this to true for detailed logging: logger: false, }); const useHydration = false; const docHook = (tdoc, _) => { console.info(`${++counter} / ${total}`); return tdoc; }; const total = workspace.docs.length; let counter = 0; if (useHydration) { const hydrated = JSON.stringify(hydrate(workspace)); fs.writeFileSync("hydrated.json", hydrated); const html = hydrate2Html( JSON.parse(fs.readFileSync("hydrated.json", "utf-8")), { ...DEFAULT_CONFIG, unwrapRoot: true, docHook, } ); } else { var html = rem2Html(workspace, { ...DEFAULT_CONFIG, docHook }); } fastify.get("/", (request, reply) => { return reply.code(200).type("text/html").send(`