0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/server/storage/index.js
Harry Wolff 66845def85 Moves storage module to use prototypes for inheritance and structure.
addresses #2852

- Moves storage modules to use prototypes and to create prototypes
that inherit from the base storage ctor.

- Makes storage/base conform to an all Promise interface.
2014-09-12 21:41:29 -04:00

26 lines
No EOL
741 B
JavaScript

var errors = require('../errors'),
storage = {};
function getStorage(storageChoice) {
// TODO: this is where the check for storage apps should go
// Local file system is the default. Fow now that is all we support.
storageChoice = 'localfilesystem';
if (storage[storageChoice]) {
return storage[storageChoice];
}
try {
// TODO: determine if storage has all the necessary methods.
storage[storageChoice] = require('./' + storageChoice);
} catch (e) {
errors.logError(e);
}
// Instantiate and cache the storage module instance.
storage[storageChoice] = new storage[storageChoice]();
return storage[storageChoice];
}
module.exports.getStorage = getStorage;