mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
96d075c47d
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!
32 lines
1.0 KiB
JavaScript
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
|
|
}
|
|
};
|