mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 14:22:07 +03:00
7619ad31d4
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings - When the yaml parser is injected through a DI it's easier to test and later on the redirects service initialization would use same pattern with exactly the same yamlParse funciton - Next step is getting yaml parser into an outside module - Also simplified getSettingFilePath method while swapping to an updated yaml parser implementation. Now this method function is exactly like the one used in redirects
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const routeSettings = require('./route-settings');
|
|
const SettingsLoader = require('./settings-loader');
|
|
const config = require('../../../shared/config');
|
|
const parseYaml = require('./yaml-parser');
|
|
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({parseYaml});
|
|
|
|
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
|
|
}
|
|
};
|