import path from "node:path"; // Common MIME types const mimeTypes: Record = { ".html": "text/html", ".htm": "text/html", ".css": "text/css", ".js": "application/javascript", ".json": "application/json", ".xml": "application/xml", ".txt": "text/plain", ".md": "text/markdown", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp", ".svg": "image/svg+xml", ".ico": "image/x-icon", ".pdf": "application/pdf", ".zip": "application/zip", ".woff": "font/woff", ".woff2": "font/woff2", ".ttf": "font/ttf", ".otf": "font/otf", ".eot": "application/vnd.ms-fontobject", ".mp4": "video/mp4", ".webm": "video/webm", ".mp3": "audio/mpeg", ".wav": "audio/wav", }; /** * Gets the content type for a file based on its extension * * @param filePath Path to the file * @returns The content type for the file */ export function getContentType(filePath: string): string { const extension = path.extname(filePath).toLowerCase(); return mimeTypes[extension] || "application/octet-stream"; }