@scalar/fastify-api-reference
Version:
a fastify plugin to render an API reference from an OpenAPI file
19 lines (18 loc) • 618 B
JavaScript
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
function getJavaScriptFile() {
const dirname = path.dirname(fileURLToPath(import.meta.url));
const filePath = [
path.resolve(`${dirname}/js/standalone.js`),
path.resolve(`${dirname}/../../dist/js/standalone.js`)
].find((file) => fs.existsSync(file));
if (filePath === void 0) {
throw new Error(`JavaScript file not found: ${path.resolve(`${dirname}/js/standalone.js`)}`);
}
return fs.readFileSync(filePath, "utf8");
}
export {
getJavaScriptFile
};
//# sourceMappingURL=getJavaScriptFile.js.map