MCPcopy Create free account
hub / github.com/scalar/scalar / getJavaScriptFile

Function getJavaScriptFile

integrations/fastify/src/utils/getJavaScriptFile.ts:20–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18 * uses (for example when bundling a Fastify app into a Docker image).
19 */
20export function getJavaScriptFile(): string {
21 try {
22 // The main entry resolves to `<pkg>/dist/index.js`, so the standalone build
23 // sits next to it under `browser/`.
24 const entry = require.resolve('@scalar/api-reference')
25 return fs.readFileSync(path.join(path.dirname(entry), 'browser/standalone.js'), 'utf-8')
26 } catch (cause) {
27 throw new Error(
28 '[@scalar/fastify-api-reference] Could not read the standalone build of `@scalar/api-reference`. Build `@scalar/api-reference` first (e.g. `pnpm build:packages`).',
29 { cause },
30 )
31 }
32}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected