qwebs-http
Version:
Http/https server for Qwebs
40 lines (35 loc) • 1.41 kB
JavaScript
/*!
* qwebs
* Copyright(c) 2015 Benoît Claveau <benoit.claveau@gmail.com>
* MIT Licensed
*/
"use strict";
const { Error } = require("oups");
class ContentTypeProvider {
constructor() {
};
get(ext) {
switch (ext) {
case ".json": return "application/json";
case ".png": return "image/png";
case ".jpg": return "image/jpg";
case ".gif": return "image/gif";
case ".svg": return "image/svg+xml";
case ".js": return "application/javascript";
case ".html": return "text/html";
case ".css": return "text/css";
case ".ico": return "image/x-icon";
case ".ttf": return "application/x-font-ttf";
case ".eot": return "application/vnd.ms-fontobject";
case ".woff": return "application/font-woff";
case ".appcache": return "text/cache-manifest";
case ".txt": return "text/plain";
case ".xml": return "application/xml";
case ".map": return "application/json";
case ".md": return "text/x-markdown";
case ".apk": return "application/vnd.android.package-archive";
default: throw new Error(`Extension ${extension} is not supported.`, { extension: ext });
};
};
};
exports = module.exports = ContentTypeProvider;