Ghost/core/server/storage/index.js
Blaine Bublitz 5c640e95f5 Initial implementation for custom storage engines
closes #4600
- implemented as suggested in #4600
- loads a custom storage defined in config from the /content/storage directory
2015-03-19 22:34:01 -07:00

31 lines
784 B
JavaScript

var errors = require('../errors'),
config = require('../config'),
storage = {};
function getStorage(storageChoice) {
var storagePath,
storageConfig;
storageChoice = config.storage.active;
storagePath = config.paths.storage;
storageConfig = config.storage[storageChoice];
if (storage[storageChoice]) {
return storage[storageChoice];
}
try {
// TODO: determine if storage has all the necessary methods.
storage[storageChoice] = require(storagePath);
} catch (e) {
errors.logError(e);
}
// Instantiate and cache the storage module instance.
storage[storageChoice] = new storage[storageChoice](storageConfig);
return storage[storageChoice];
}
module.exports.getStorage = getStorage;