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

Function prepareStaticFile

packages/fresh/src/dev/dev_build_cache.ts:561–588  ·  view source on GitHub ↗
(
  item: PendingStaticFile,
  outDir: string,
)

Source from the content-addressed store, hash-verified

559}
560
561export async function prepareStaticFile(
562 item: PendingStaticFile,
563 outDir: string,
564): Promise<
565 {
566 name: string;
567 hash: string;
568 filePath: string;
569 contentType: string;
570 immutable?: boolean;
571 }
572> {
573 const file = await Deno.open(item.filePath);
574 const hash = item.hash ? item.hash : await hashContent(file.readable);
575 const encodedPathname = systemPathToUrlEncoded(item.pathname);
576
577 return {
578 name: encodedPathname,
579 hash,
580 filePath: toPosix(
581 path.isAbsolute(item.filePath)
582 ? path.relative(outDir, item.filePath)
583 : item.filePath,
584 ),
585 contentType: getContentType(item.filePath),
586 immutable: item.immutable,
587 };
588}
589
590export function generateServerEntry(
591 options: {

Callers 3

generateSnapshotServerFunction · 0.85
writeBundleFunction · 0.85

Calls 5

hashContentFunction · 0.85
systemPathToUrlEncodedFunction · 0.85
toPosixFunction · 0.85
openMethod · 0.80
getContentTypeFunction · 0.70

Tested by

no test coverage detected