loopback-component-storage/lib/factory.js

20 lines
554 B
JavaScript
Raw Normal View History

2013-07-02 14:54:58 +00:00
function createClient(options) {
2013-06-24 23:57:16 +00:00
options = options || {};
2013-06-25 16:29:53 +00:00
var provider = options.provider || 'filesystem';
2013-06-24 23:57:16 +00:00
if ('function' !== typeof provider) {
try {
// Try to load the provider from providers folder
provider = require('./providers/' + provider);
} catch (err) {
// Fall back to pkgcloud
return require('pkgcloud').storage.createClient(options);
}
}
return new provider(options);
2013-07-02 14:54:58 +00:00
}
module.exports = createClient;
module.exports.createClient = createClient;