Ghost/core/server/services/adapter-manager/index.js
Vikas Potluri 15d9a77092
Moved config from server to shared (#11850)
* moved `server/config` to `shared/config`
* updated config import paths in server to use shared
* updated config import paths in frontend to use shared
* updated config import paths in test to use shared
* updated config import paths in root to use shared
* trigger regression tests
* of course the rebase broke tests
2020-05-27 18:47:53 +01:00

29 lines
1.1 KiB
JavaScript

const AdapterManager = require('@tryghost/adapter-manager');
const getAdapterServiceConfig = require('./config');
const config = require('../../../shared/config');
const adapterManager = new AdapterManager({
loadAdapterFromPath: require,
pathsToAdapters: [
'', // A blank path will cause us to check node_modules for the adapter
config.getContentPath('adapters'),
config.get('paths').internalAdaptersPath
]
});
adapterManager.registerAdapter('storage', require('ghost-storage-base'));
adapterManager.registerAdapter('scheduling', require('../../adapters/scheduling/SchedulingBase'));
adapterManager.registerAdapter('sso', require('../../adapters/sso/Base'));
module.exports = {
getAdapter(adapterType) {
const adapterServiceConfig = getAdapterServiceConfig(config);
const adapterSettings = adapterServiceConfig[adapterType];
const activeAdapter = adapterSettings.active;
const activeAdapterConfig = adapterSettings[activeAdapter];
return adapterManager.getAdapter(adapterType, activeAdapter, activeAdapterConfig);
}
};