MCPcopy
hub / github.com/freshframework/fresh / generateServerEntry

Function generateServerEntry

packages/fresh/src/dev/dev_build_cache.ts:590–623  ·  view source on GitHub ↗
(
  options: {
    root: string;
    serverEntry: string;
    snapshotSpecifier: string;
  },
)

Source from the content-addressed store, hash-verified

588}
589
590export function generateServerEntry(
591 options: {
592 root: string;
593 serverEntry: string;
594 snapshotSpecifier: string;
595 },
596): string {
597 const root = toPosix(options.root);
598 const serverEntry = toPosix(options.serverEntry);
599 const snapshotSpecifier = toPosix(options.snapshotSpecifier);
600
601 let rootPath = `path.join(import.meta.dirname, ${JSON.stringify(root)})`;
602 if (path.isAbsolute(root)) {
603 // deno-lint-ignore no-console
604 console.warn(
605 `WARN: using absolute root path in snapshot: "${root}"`,
606 );
607
608 rootPath = JSON.stringify(root);
609 }
610
611 return `${EDIT_WARNING}
612import { setBuildCache, ProdBuildCache, path } from "fresh/internal";
613import * as snapshot from "${snapshotSpecifier}";
614import { app } from "${serverEntry}";
615
616const root = ${rootPath};
617setBuildCache(app, new ProdBuildCache(root, snapshot), "production");
618
619export default {
620 fetch: app.handler()
621};
622`;
623}
624
625function getClientEntry(buildId: string) {
626 return `/_fresh/js/${buildId}/fresh-runtime.js`;

Callers 3

flushMethod · 0.85
handlerFunction · 0.85

Calls 2

toPosixFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected