file server content type headers

This commit is contained in:
2025-01-20 23:45:07 -07:00
parent 3b1a969145
commit fcba2014c2
4 changed files with 36 additions and 2 deletions

26
util/contentType.ts Executable file
View File

@@ -0,0 +1,26 @@
export function getContentTypeByExtension(extension: string) {
switch (extension) {
case "html":
case "htm":
return "text/html";
case "css":
return "text/css";
case "js":
return "text/javascript";
case "json":
return "application/json";
case "png":
return "image/png";
case "jpg":
case "jpeg":
return "image/jpeg";
case "gif":
return "image/gif";
case "svg":
return "image/svg+xml";
case "txt":
return "text/plain";
default:
return "application/octet-stream";
}
}