mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
6d6aa12afe
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)
- The full logic for file path calculation for routes.yaml has been duplicated in couple modules. It is aslo following similar pattern used in redirects services and should be reused there once those modules are touched
36 lines
1.1 KiB
JavaScript
36 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,
|
|
storageFolderPath: config.getContentPath('settings')
|
|
});
|
|
|
|
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
|
|
}
|
|
};
|