diff --git a/core/bbs.js b/core/bbs.js index 75446c45..c43d63a3 100644 --- a/core/bbs.js +++ b/core/bbs.js @@ -179,6 +179,9 @@ function initialize(cb) { function initDatabases(callback) { return database.initializeDatabases(callback); }, + function initMimeTypes(callback) { + return require('./mime_util.js').startup(callback); + }, function initStatLog(callback) { return require('./stat_log.js').init(callback); }, diff --git a/core/mime_util.js b/core/mime_util.js index ca7ab50e..0963d5e5 100644 --- a/core/mime_util.js +++ b/core/mime_util.js @@ -1,10 +1,33 @@ /* jslint node: true */ 'use strict'; +// deps +const _ = require('lodash'); + const mimeTypes = require('mime-types'); +exports.startup = startup; exports.resolveMimeType = resolveMimeType; +function startup(cb) { + // + // Add in types (not yet) supported by mime-db -- and therefor, mime-types + // + const ADDITIONAL_EXT_MIMETYPES = { + arj : 'application/x-arj', + ans : 'text/x-ansi', + }; + + _.forEach(ADDITIONAL_EXT_MIMETYPES, (mimeType, ext) => { + // don't override any entries + if(!_.isString(mimeTypes.types[ext])) { + mimeTypes[ext] = mimeType; + } + }); + + return cb(null); +} + function resolveMimeType(query) { if(mimeTypes.extensions[query]) { return query; // alreaed a mime-type