12 lines
382 B
TypeScript

import { Mime } from "mime/lite";
import standardTypes from "mime/types/standard.js";
import otherTypes from "mime/types/other.js";
const mime = new Mime(standardTypes, otherTypes);
mime.define({ "text/javascript": ["jsx", "tsx", "ts"] }, true);
export const getMimeType = (
ext: string,
defaultMime: string = "application/octet-stream"
) => mime.getType(ext) || defaultMime;