2014-08-28 22:48:49 -05:00
|
|
|
var errors = require('../errors'),
|
|
|
|
storage = {};
|
2013-11-07 11:00:39 -05:00
|
|
|
|
2014-08-28 22:48:49 -05:00
|
|
|
function getStorage(storageChoice) {
|
2014-01-21 03:45:27 -05:00
|
|
|
// TODO: this is where the check for storage apps should go
|
2014-08-28 22:48:49 -05:00
|
|
|
// Local file system is the default. Fow now that is all we support.
|
2014-09-19 11:17:58 -05:00
|
|
|
storageChoice = 'local-file-store';
|
2013-11-07 11:00:39 -05:00
|
|
|
|
2014-08-28 22:48:49 -05:00
|
|
|
if (storage[storageChoice]) {
|
|
|
|
return storage[storageChoice];
|
2013-11-07 11:00:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2014-08-28 22:48:49 -05:00
|
|
|
// TODO: determine if storage has all the necessary methods.
|
|
|
|
storage[storageChoice] = require('./' + storageChoice);
|
2013-11-07 11:00:39 -05:00
|
|
|
} catch (e) {
|
|
|
|
errors.logError(e);
|
|
|
|
}
|
2014-08-28 22:48:49 -05:00
|
|
|
|
|
|
|
// Instantiate and cache the storage module instance.
|
|
|
|
storage[storageChoice] = new storage[storageChoice]();
|
|
|
|
|
|
|
|
return storage[storageChoice];
|
2013-11-07 11:00:39 -05:00
|
|
|
}
|
|
|
|
|
2014-09-09 23:06:24 -05:00
|
|
|
module.exports.getStorage = getStorage;
|