mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
d4cd1bb865
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings - Ensure settings had only one method but would benefit from class+DI pattern before extracting it into an outside module. - The logic is now also less coupled with "routes" and single source/destination paths. It's all configureable instead and might be reused if similar pattern is needed for example with redirect settings defaults.
30 lines
938 B
JavaScript
30 lines
938 B
JavaScript
const routeSettings = require('./route-settings');
|
|
const SettingsLoader = require('./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
|
|
});
|
|
|
|
module.exports = {
|
|
init: async () => {
|
|
return await defaultSettingsManager.ensureSettingsFileExists();
|
|
},
|
|
|
|
loadRouteSettingsSync: SettingsLoader.loadSettingsSync,
|
|
loadRouteSettings: SettingsLoader.loadSettings,
|
|
getDefaultHash: routeSettings.getDefaultHash,
|
|
/**
|
|
* Methods used in the API
|
|
*/
|
|
api: {
|
|
setFromFilePath: routeSettings.setFromFilePath,
|
|
get: routeSettings.get,
|
|
getCurrentHash: routeSettings.getCurrentHash
|
|
}
|
|
};
|