Ghost/core/server/services/route-settings/index.js
Naz 96d075c47d Refactored settings loader to class
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- It's a step to making the module follow class+DI pattern before fully extracting it into an external libarary
- Reminder, doing in Ghost repo instead of substituting big chunks all at once to have clear history of how the service evolved prior to the extraction into external lib!
2021-09-30 17:29:42 +02:00

32 lines
1.0 KiB
JavaScript

const routeSettings = require('./route-settings');
const SettingsLoader = require('./settings-loader');
const config = require('../../../shared/config');
const DefaultSettingsManager = require('./default-settings-manager');
const defaultSettingsManager = new DefaultSettingsManager({
type: 'routes',
extension: '.yaml',
destinationFolderPath: config.getContentPath('settings'),
sourceFolderPath: config.get('paths').defaultSettings
});
const settingsLoader = new SettingsLoader();
module.exports = {
init: async () => {
return await defaultSettingsManager.ensureSettingsFileExists();
},
loadRouteSettingsSync: settingsLoader.loadSettingsSync.bind(settingsLoader),
loadRouteSettings: settingsLoader.loadSettings.bind(settingsLoader),
getDefaultHash: routeSettings.getDefaultHash,
/**
* Methods used in the API
*/
api: {
setFromFilePath: routeSettings.setFromFilePath,
get: routeSettings.get,
getCurrentHash: routeSettings.getCurrentHash
}
};