Moved route settings to new server service

- The main goal here is getting this settings related code out of the routing service as it really doesn't belong there
- This settings file is used purely by the API to get and set files - its not really anything to do with actual routing
- This file calls out to the bridge to do a reload, which helps decouple slightly
- More refactoring is needed to get rid of the urlService dependency
- Note this file is really similar to the redirects one, it would be good to merge them
This commit is contained in:
Hannah Wolfe 2021-06-28 12:09:02 +01:00
parent 32a09dc9c6
commit 8612f3aaeb
No known key found for this signature in database
GPG Key ID: 9F8C7532D0A6BA55
6 changed files with 12 additions and 15 deletions

View File

@ -7,10 +7,6 @@ module.exports = {
return require('./registry');
},
get settings() {
return require('./settings');
},
get helpers() {
return require('./helpers');
},

View File

@ -2,7 +2,7 @@ const Promise = require('bluebird');
const _ = require('lodash');
const validator = require('@tryghost/validator');
const models = require('../../models');
const frontendRouting = require('../../../frontend/services/routing');
const routeSettings = require('../../services/route-settings');
const frontendSettings = require('../../../frontend/services/settings');
const i18n = require('../../../shared/i18n');
const {BadRequestError, NoPermissionError, NotFoundError} = require('@tryghost/errors');
@ -328,7 +328,7 @@ module.exports = {
method: 'edit'
},
async query(frame) {
await frontendRouting.settings.setFromFilePath(frame.file.path);
await routeSettings.setFromFilePath(frame.file.path);
const getRoutesHash = () => frontendSettings.getCurrentHash('routes');
await settingsService.syncRoutesHash(getRoutesHash);
}
@ -348,7 +348,7 @@ module.exports = {
method: 'browse'
},
query() {
return frontendRouting.settings.get();
return routeSettings.get();
}
}
};

View File

@ -1,7 +1,7 @@
const Promise = require('bluebird');
const _ = require('lodash');
const models = require('../../models');
const frontendRouting = require('../../../frontend/services/routing');
const routeSettings = require('../../services/route-settings');
const frontendSettings = require('../../../frontend/services/settings');
const i18n = require('../../../shared/i18n');
const {NoPermissionError, NotFoundError} = require('@tryghost/errors');
@ -168,7 +168,7 @@ module.exports = {
method: 'edit'
},
async query(frame) {
await frontendRouting.settings.setFromFilePath(frame.file.path);
await routeSettings.setFromFilePath(frame.file.path);
const getRoutesHash = () => frontendSettings.getCurrentHash('routes');
await settingsService.syncRoutesHash(getRoutesHash);
}
@ -188,7 +188,7 @@ module.exports = {
method: 'browse'
},
query() {
return frontendRouting.settings.get();
return routeSettings.get();
}
}
};

View File

@ -2,7 +2,7 @@ const Promise = require('bluebird');
const _ = require('lodash');
const validator = require('@tryghost/validator');
const models = require('../../models');
const frontendRouting = require('../../../frontend/services/routing');
const routeSettings = require('../../services/route-settings');
const frontendSettings = require('../../../frontend/services/settings');
const i18n = require('../../../shared/i18n');
const {BadRequestError, NoPermissionError, NotFoundError} = require('@tryghost/errors');
@ -313,7 +313,7 @@ module.exports = {
method: 'edit'
},
async query(frame) {
await frontendRouting.settings.setFromFilePath(frame.file.path);
await routeSettings.settings.setFromFilePath(frame.file.path);
const getRoutesHash = () => frontendSettings.getCurrentHash('routes');
await settingsService.syncRoutesHash(getRoutesHash);
}
@ -333,7 +333,7 @@ module.exports = {
method: 'browse'
},
query() {
return frontendRouting.settings.get();
return routeSettings.settings.get();
}
}
};

View File

@ -0,0 +1 @@
module.exports = require('./route-settings');

View File

@ -2,9 +2,9 @@ const Promise = require('bluebird');
const moment = require('moment-timezone');
const fs = require('fs-extra');
const path = require('path');
const urlService = require('../url');
const urlService = require('../../../frontend/services/url');
const debug = require('@tryghost/debug')('services:frontend:routing:settings');
const debug = require('@tryghost/debug')('services:route-settings');
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
const config = require('../../../shared/config');