* Serves a static file with proper MIME type, or returns null if not found
(filePath: string)
| 44 | * Serves a static file with proper MIME type, or returns null if not found |
| 45 | */ |
| 46 | function 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 |
no test coverage detected