/** * @file Self-hosted ReDoc API reference. ReDoc renders the OpenAPI spec as a * clean, three-panel reference document — a read-optimized complement to * Swagger UI's interactive "try it out" console (both are served from the same * `/api/openapi.json` spec). The ReDoc bundle is served from the repo itself * rather than a CDN, so the docs render fully offline / air-gapped, consistent * with the project's no-external-assets policy. * * The bundle is VENDORED (`server/vendor/redoc/`): `redoc.standalone.js` from * the `redoc` npm package 2.5.4, byte-for-byte, with its MIT `LICENSE` and the * bundled libraries' `redoc.standalone.js.LICENSE.txt`. The `redoc` package * itself is not a dependency — the server only ever serves this one browser * file, and the package pulled ~25 MB of Node-side dependencies into every * runtime install. To update: `npm pack redoc@`, copy * `package/bundles/redoc.standalone.js` (+ `.LICENSE.txt`) over these files and * bump the version named here. * @author Nguyễn Ngọc Trí Vĩ */ const path = require("path"); /** * Absolute path to the vendored ReDoc standalone bundle. * @returns {string} */ function redocBundlePath() { return path.join(__dirname, "..", "vendor", "redoc", "redoc.standalone.js"); } /** * Minimal HTML shell that boots ReDoc against a spec URL using the * locally-served bundle. Makes no external network requests. * * @param {string} specUrl URL the browser fetches the OpenAPI JSON from. * @param {string} bundleUrl URL the page loads the ReDoc bundle from. * @param {string} title Document and browser-tab label. * @returns {string} A complete HTML document. */ function renderRedocHtml(specUrl, bundleUrl, title) { return `<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>${title} `; } module.exports = { redocBundlePath, renderRedocHtml };