From 0366f0139c82b55d8ac346b4787f9eae82acf794 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Fri, 23 Jun 2017 22:49:46 -0600 Subject: [PATCH] Add application/x-arj and text/x-ansi MIME types --- core/bbs.js | 3 +++ core/mime_util.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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