MCPcopy Create free account
hub / github.com/MarsWang42/Awel / serveStaticFile

Function serveStaticFile

packages/cli/src/server.ts:46–55  ·  view source on GitHub ↗

* Serves a static file with proper MIME type, or returns null if not found

(filePath: string)

Source from the content-addressed store, hash-verified

44 * Serves a static file with proper MIME type, or returns null if not found
45 */
46function serveStaticFile(filePath: string): { content: ArrayBuffer; mimeType: string } | null {
47 if (!existsSync(filePath)) return null;
48 const buffer = readFileSync(filePath);
49 // Convert Node Buffer to ArrayBuffer for Hono compatibility
50 const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength) as ArrayBuffer;
51 return {
52 content: arrayBuffer,
53 mimeType: getMimeType(filePath)
54 };
55}
56
57/**
58 * Serves the dashboard index.html, or returns null if not found

Callers 1

startServerFunction · 0.85

Calls 1

getMimeTypeFunction · 0.85

Tested by

no test coverage detected