From c3b14f82fd1f35ce4dbaa89ba934d28b50a3caa8 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 20 Jun 2019 13:19:22 +0200 Subject: [PATCH 1/9] Moved settings#upload method out of settings controller --- .../services/routing/SettingsHandler.js | 70 +++++++++++++++++++ core/frontend/services/routing/index.js | 4 ++ core/frontend/services/themes/index.js | 3 + core/server/api/v2/settings.js | 60 +--------------- 4 files changed, 79 insertions(+), 58 deletions(-) create mode 100644 core/frontend/services/routing/SettingsHandler.js diff --git a/core/frontend/services/routing/SettingsHandler.js b/core/frontend/services/routing/SettingsHandler.js new file mode 100644 index 0000000000..53987303cd --- /dev/null +++ b/core/frontend/services/routing/SettingsHandler.js @@ -0,0 +1,70 @@ +const moment = require('moment-timezone'); +const fs = require('fs-extra'); +const path = require('path'); +const urlService = require('../url'); + +const common = require('../../../server/lib/common'); +const config = require('../../../server/config'); + +const activate = (filePath) => { + const settingsPath = config.getContentPath('settings'); + const backupRoutesPath = path.join(settingsPath, `routes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.yaml`); + + return fs.copy(`${settingsPath}/routes.yaml`, backupRoutesPath) + .then(() => { + return fs.copy(filePath, `${settingsPath}/routes.yaml`); + }) + .then(() => { + urlService.resetGenerators({releaseResourcesOnly: true}); + }) + .then(() => { + const siteApp = require('../../../server/web/site/app'); + + const bringBackValidRoutes = () => { + urlService.resetGenerators({releaseResourcesOnly: true}); + + return fs.copy(backupRoutesPath, `${settingsPath}/routes.yaml`) + .then(() => { + return siteApp.reload(); + }); + }; + + try { + siteApp.reload(); + } catch (err) { + return bringBackValidRoutes() + .finally(() => { + throw err; + }); + } + + let tries = 0; + + function isBlogRunning() { + return Promise.delay(1000) + .then(() => { + if (!urlService.hasFinished()) { + if (tries > 5) { + throw new common.errors.InternalServerError({ + message: 'Could not load routes.yaml file.' + }); + } + + tries = tries + 1; + return isBlogRunning(); + } + }); + } + + return isBlogRunning() + .catch((err) => { + return bringBackValidRoutes() + .finally(() => { + throw err; + }); + }); + }); +}; + +module.exports.activate = activate; +// module.exports.serve = serve; diff --git a/core/frontend/services/routing/index.js b/core/frontend/services/routing/index.js index 2a480bc74a..c7bf68edeb 100644 --- a/core/frontend/services/routing/index.js +++ b/core/frontend/services/routing/index.js @@ -17,5 +17,9 @@ module.exports = { get TaxonomyRouter() { return require('./TaxonomyRouter'); + }, + + get settings() { + return require('./SettingsHandler'); } }; diff --git a/core/frontend/services/themes/index.js b/core/frontend/services/themes/index.js index 60d95c4b7a..f3bec1f031 100644 --- a/core/frontend/services/themes/index.js +++ b/core/frontend/services/themes/index.js @@ -96,6 +96,9 @@ module.exports = { } else { return engineDefaults['ghost-api']; } + }, + delete: function (){ + }, activate: function activate(loadedTheme, checkedTheme, error) { // no need to check the score, activation should be used in combination with validate.check diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index 4823e9ab8c..98779b8a6c 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -1,11 +1,10 @@ const Promise = require('bluebird'); const _ = require('lodash'); -const moment = require('moment-timezone'); const fs = require('fs-extra'); const path = require('path'); const config = require('../../config'); const models = require('../../models'); -const urlService = require('../../../frontend/services/url'); +const frontendRouting = require('../../../frontend/services/routing'); const common = require('../../lib/common'); const settingsCache = require('../../services/settings/cache'); @@ -151,62 +150,7 @@ module.exports = { method: 'edit' }, query(frame) { - const backupRoutesPath = path.join(config.getContentPath('settings'), `routes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.yaml`); - - return fs.copy(`${config.getContentPath('settings')}/routes.yaml`, backupRoutesPath) - .then(() => { - return fs.copy(frame.file.path, `${config.getContentPath('settings')}/routes.yaml`); - }) - .then(() => { - urlService.resetGenerators({releaseResourcesOnly: true}); - }) - .then(() => { - const siteApp = require('../../web/site/app'); - - const bringBackValidRoutes = () => { - urlService.resetGenerators({releaseResourcesOnly: true}); - - return fs.copy(backupRoutesPath, `${config.getContentPath('settings')}/routes.yaml`) - .then(() => { - return siteApp.reload(); - }); - }; - - try { - siteApp.reload(); - } catch (err) { - return bringBackValidRoutes() - .finally(() => { - throw err; - }); - } - - let tries = 0; - - function isBlogRunning() { - return Promise.delay(1000) - .then(() => { - if (!urlService.hasFinished()) { - if (tries > 5) { - throw new common.errors.InternalServerError({ - message: 'Could not load routes.yaml file.' - }); - } - - tries = tries + 1; - return isBlogRunning(); - } - }); - } - - return isBlogRunning() - .catch((err) => { - return bringBackValidRoutes() - .finally(() => { - throw err; - }); - }); - }); + return frontendRouting.settings.activate(frame.file.path); } }, From 8709f5cc555d93e9e328d16b21b7d48533f87961 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 20 Jun 2019 13:23:58 +0200 Subject: [PATCH 2/9] Moved out code from download to serve method --- .../services/routing/SettingsHandler.js | 21 ++++++++++++++++++- core/server/api/v2/settings.js | 20 +----------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core/frontend/services/routing/SettingsHandler.js b/core/frontend/services/routing/SettingsHandler.js index 53987303cd..de03b599f1 100644 --- a/core/frontend/services/routing/SettingsHandler.js +++ b/core/frontend/services/routing/SettingsHandler.js @@ -66,5 +66,24 @@ const activate = (filePath) => { }); }; +const serve = () => { + const routesPath = path.join(config.getContentPath('settings'), 'routes.yaml'); + + return fs.readFile(routesPath, 'utf-8') + .catch((err) => { + if (err.code === 'ENOENT') { + return Promise.resolve([]); + } + + if (common.errors.utils.isIgnitionError(err)) { + throw err; + } + + throw new common.errors.NotFoundError({ + err: err + }); + }); +}; + module.exports.activate = activate; -// module.exports.serve = serve; +module.exports.serve = serve; diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index 98779b8a6c..7425a019a7 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -1,8 +1,5 @@ const Promise = require('bluebird'); const _ = require('lodash'); -const fs = require('fs-extra'); -const path = require('path'); -const config = require('../../config'); const models = require('../../models'); const frontendRouting = require('../../../frontend/services/routing'); const common = require('../../lib/common'); @@ -168,22 +165,7 @@ module.exports = { method: 'browse' }, query() { - const routesPath = path.join(config.getContentPath('settings'), 'routes.yaml'); - - return fs.readFile(routesPath, 'utf-8') - .catch((err) => { - if (err.code === 'ENOENT') { - return Promise.resolve([]); - } - - if (common.errors.utils.isIgnitionError(err)) { - throw err; - } - - throw new common.errors.NotFoundError({ - err: err - }); - }); + return frontendRouting.settings.serve(); } } }; From 06a6dc835dcc6f7ac540f5efb11309f320df0539 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 20 Jun 2019 13:34:22 +0200 Subject: [PATCH 3/9] Moved API v0.1 settings upload/downalod routes.yaml methods to use setting handler service --- .../services/routing/SettingsHandler.js | 11 ++++ core/server/api/v0.1/settings.js | 60 +------------------ 2 files changed, 14 insertions(+), 57 deletions(-) diff --git a/core/frontend/services/routing/SettingsHandler.js b/core/frontend/services/routing/SettingsHandler.js index de03b599f1..116bc983fd 100644 --- a/core/frontend/services/routing/SettingsHandler.js +++ b/core/frontend/services/routing/SettingsHandler.js @@ -6,6 +6,17 @@ const urlService = require('../url'); const common = require('../../../server/lib/common'); const config = require('../../../server/config'); +/** + * The `routes.yaml` file offers a way to configure your Ghost blog. It's currently a setting feature + * we have added. That's why the `routes.yaml` file is treated as a "setting" right now. + * If we want to add single permissions for this file (e.g. upload/download routes.yaml), we can add later. + * + * How does it work? + * + * - we first reset all url generators (each url generator belongs to one express router) + * - we don't destroy the resources, we only release them (this avoids reloading all resources from the db again) + * - then we reload the whole site app, which will reset all routers and re-create the url generators + */ const activate = (filePath) => { const settingsPath = config.getContentPath('settings'); const backupRoutesPath = path.join(settingsPath, `routes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.yaml`); diff --git a/core/server/api/v0.1/settings.js b/core/server/api/v0.1/settings.js index 06e4526204..a3fb87c325 100644 --- a/core/server/api/v0.1/settings.js +++ b/core/server/api/v0.1/settings.js @@ -2,14 +2,10 @@ // RESTful API for the Setting resource const Promise = require('bluebird'), _ = require('lodash'), - moment = require('moment-timezone'), - fs = require('fs-extra'), - path = require('path'), - config = require('../../config'), models = require('../../models'), canThis = require('../../services/permissions').canThis, localUtils = require('./utils'), - urlService = require('../../../frontend/services/url'), + frontendRouting = require('../../../frontend/services/routing'), common = require('../../lib/common'), settingsCache = require('../../services/settings/cache'), docName = 'settings'; @@ -255,67 +251,17 @@ settings = { }); }, - /** - * The `routes.yaml` file offers a way to configure your Ghost blog. It's currently a setting feature - * we have added. That's why the `routes.yaml` file is treated as a "setting" right now. - * If we want to add single permissions for this file (e.g. upload/download routes.yaml), we can add later. - * - * How does it work? - * - * - we first reset all url generators (each url generator belongs to one express router) - * - we don't destroy the resources, we only release them (this avoids reloading all resources from the db again) - * - then we reload the whole site app, which will reset all routers and re-create the url generators - */ upload(options) { - const backupRoutesPath = path.join(config.getContentPath('settings'), `routes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.yaml`); - return localUtils.handlePermissions('settings', 'edit')(options) .then(() => { - return fs.copy(`${config.getContentPath('settings')}/routes.yaml`, backupRoutesPath); - }) - .then(() => { - return fs.copy(options.path, `${config.getContentPath('settings')}/routes.yaml`); - }) - .then(() => { - urlService.resetGenerators({releaseResourcesOnly: true}); - }) - .then(() => { - const siteApp = require('../../web/site/app'); - - try { - return siteApp.reload(); - } catch (err) { - // bring back backup, otherwise your Ghost blog is broken - return fs.copy(backupRoutesPath, `${config.getContentPath('settings')}/routes.yaml`) - .then(() => { - return siteApp.reload(); - }) - .then(() => { - throw err; - }); - } + return frontendRouting.settings.activate(options.path); }); }, download(options) { - const routesPath = path.join(config.getContentPath('settings'), 'routes.yaml'); - return localUtils.handlePermissions('settings', 'browse')(options) .then(() => { - return fs.readFile(routesPath, 'utf-8'); - }) - .catch((err) => { - if (err.code === 'ENOENT') { - return Promise.resolve([]); - } - - if (common.errors.utils.isIgnitionError(err)) { - throw err; - } - - throw new common.errors.NotFoundError({ - err: err - }); + return frontendRouting.settings.serve(); }); } }; From dc68f37b8669496cc844e6f667d3319e54ca811a Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 20 Jun 2019 16:27:37 +0200 Subject: [PATCH 4/9] Reverted unintended change --- core/frontend/services/themes/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/frontend/services/themes/index.js b/core/frontend/services/themes/index.js index f3bec1f031..60d95c4b7a 100644 --- a/core/frontend/services/themes/index.js +++ b/core/frontend/services/themes/index.js @@ -96,9 +96,6 @@ module.exports = { } else { return engineDefaults['ghost-api']; } - }, - delete: function (){ - }, activate: function activate(loadedTheme, checkedTheme, error) { // no need to check the score, activation should be used in combination with validate.check From 61dc9e8c24cc656f63e0b4948930b0c5b58e0351 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 20 Jun 2019 16:58:26 +0200 Subject: [PATCH 5/9] Moved RoutesHandler into settings module - To keep in convention with settings described in - https://github.com/TryGhost/Ghost/issues/9528 , extracted routes handler into separate settings folder --- core/frontend/services/routing/index.js | 4 ---- .../SettingsHandler.js => settings/RoutesHandler.js} | 0 core/frontend/services/settings/index.js | 5 +++++ core/server/api/v2/settings.js | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) rename core/frontend/services/{routing/SettingsHandler.js => settings/RoutesHandler.js} (100%) create mode 100644 core/frontend/services/settings/index.js diff --git a/core/frontend/services/routing/index.js b/core/frontend/services/routing/index.js index c7bf68edeb..2a480bc74a 100644 --- a/core/frontend/services/routing/index.js +++ b/core/frontend/services/routing/index.js @@ -17,9 +17,5 @@ module.exports = { get TaxonomyRouter() { return require('./TaxonomyRouter'); - }, - - get settings() { - return require('./SettingsHandler'); } }; diff --git a/core/frontend/services/routing/SettingsHandler.js b/core/frontend/services/settings/RoutesHandler.js similarity index 100% rename from core/frontend/services/routing/SettingsHandler.js rename to core/frontend/services/settings/RoutesHandler.js diff --git a/core/frontend/services/settings/index.js b/core/frontend/services/settings/index.js new file mode 100644 index 0000000000..1c721c2ee9 --- /dev/null +++ b/core/frontend/services/settings/index.js @@ -0,0 +1,5 @@ +module.exports = { + get routes() { + return require('./RoutesHandler'); + } +}; diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index 7425a019a7..fe0d4e0609 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -1,7 +1,7 @@ const Promise = require('bluebird'); const _ = require('lodash'); const models = require('../../models'); -const frontendRouting = require('../../../frontend/services/routing'); +const frontendSettings = require('../../../frontend/services/settings'); const common = require('../../lib/common'); const settingsCache = require('../../services/settings/cache'); @@ -147,7 +147,7 @@ module.exports = { method: 'edit' }, query(frame) { - return frontendRouting.settings.activate(frame.file.path); + return frontendSettings.routes.activate(frame.file.path); } }, @@ -165,7 +165,7 @@ module.exports = { method: 'browse' }, query() { - return frontendRouting.settings.serve(); + return frontendSettings.routes.serve(); } } }; From 19d3c4bc5ccb4cbf77f406cf6588cbe574102e5d Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 20 Jun 2019 17:20:44 +0200 Subject: [PATCH 6/9] Frontend settings for API v0.1 --- core/server/api/v0.1/settings.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/server/api/v0.1/settings.js b/core/server/api/v0.1/settings.js index a3fb87c325..3bdb0d5c6f 100644 --- a/core/server/api/v0.1/settings.js +++ b/core/server/api/v0.1/settings.js @@ -5,7 +5,7 @@ const Promise = require('bluebird'), models = require('../../models'), canThis = require('../../services/permissions').canThis, localUtils = require('./utils'), - frontendRouting = require('../../../frontend/services/routing'), + frontendSettings = require('../../../frontend/services/settings'), common = require('../../lib/common'), settingsCache = require('../../services/settings/cache'), docName = 'settings'; @@ -254,14 +254,14 @@ settings = { upload(options) { return localUtils.handlePermissions('settings', 'edit')(options) .then(() => { - return frontendRouting.settings.activate(options.path); + return frontendSettings.routes.activate(options.path); }); }, download(options) { return localUtils.handlePermissions('settings', 'browse')(options) .then(() => { - return frontendRouting.settings.serve(); + return frontendSettings.routes.serve(); }); } }; From f3b4e2e39a8600cbbd6e69efc3d2d8773da1f17c Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Fri, 21 Jun 2019 13:12:23 +0200 Subject: [PATCH 7/9] Renamed 'routes' to 'dynamic-routing' --- .../settings/{RoutesHandler.js => dynamic-routing.js} | 0 core/frontend/services/settings/index.js | 4 ++-- core/server/api/v0.1/settings.js | 4 ++-- core/server/api/v2/settings.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename core/frontend/services/settings/{RoutesHandler.js => dynamic-routing.js} (100%) diff --git a/core/frontend/services/settings/RoutesHandler.js b/core/frontend/services/settings/dynamic-routing.js similarity index 100% rename from core/frontend/services/settings/RoutesHandler.js rename to core/frontend/services/settings/dynamic-routing.js diff --git a/core/frontend/services/settings/index.js b/core/frontend/services/settings/index.js index 1c721c2ee9..ccf6c497aa 100644 --- a/core/frontend/services/settings/index.js +++ b/core/frontend/services/settings/index.js @@ -1,5 +1,5 @@ module.exports = { - get routes() { - return require('./RoutesHandler'); + get dynamicRouting() { + return require('./dynamic-routing'); } }; diff --git a/core/server/api/v0.1/settings.js b/core/server/api/v0.1/settings.js index 3bdb0d5c6f..65d60130e6 100644 --- a/core/server/api/v0.1/settings.js +++ b/core/server/api/v0.1/settings.js @@ -254,14 +254,14 @@ settings = { upload(options) { return localUtils.handlePermissions('settings', 'edit')(options) .then(() => { - return frontendSettings.routes.activate(options.path); + return frontendSettings.dynamicRouting.activate(options.path); }); }, download(options) { return localUtils.handlePermissions('settings', 'browse')(options) .then(() => { - return frontendSettings.routes.serve(); + return frontendSettings.dynamicRouting.serve(); }); } }; diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index fe0d4e0609..55eef7536a 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -147,7 +147,7 @@ module.exports = { method: 'edit' }, query(frame) { - return frontendSettings.routes.activate(frame.file.path); + return frontendSettings.dynamicRouting.activate(frame.file.path); } }, @@ -165,7 +165,7 @@ module.exports = { method: 'browse' }, query() { - return frontendSettings.routes.serve(); + return frontendSettings.dynamicRouting.serve(); } } }; From a84c15689ebe30285f8544d278f227b0b6eedf2c Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Fri, 21 Jun 2019 13:58:26 +0200 Subject: [PATCH 8/9] Renamved activate/serve methods as suggested in discussions --- core/frontend/services/settings/dynamic-routing.js | 8 ++++---- core/server/api/v0.1/settings.js | 4 ++-- core/server/api/v2/settings.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/frontend/services/settings/dynamic-routing.js b/core/frontend/services/settings/dynamic-routing.js index 116bc983fd..15f18db262 100644 --- a/core/frontend/services/settings/dynamic-routing.js +++ b/core/frontend/services/settings/dynamic-routing.js @@ -17,7 +17,7 @@ const config = require('../../../server/config'); * - we don't destroy the resources, we only release them (this avoids reloading all resources from the db again) * - then we reload the whole site app, which will reset all routers and re-create the url generators */ -const activate = (filePath) => { +const setFromFilePath = (filePath) => { const settingsPath = config.getContentPath('settings'); const backupRoutesPath = path.join(settingsPath, `routes-${moment().format('YYYY-MM-DD-HH-mm-ss')}.yaml`); @@ -77,7 +77,7 @@ const activate = (filePath) => { }); }; -const serve = () => { +const get = () => { const routesPath = path.join(config.getContentPath('settings'), 'routes.yaml'); return fs.readFile(routesPath, 'utf-8') @@ -96,5 +96,5 @@ const serve = () => { }); }; -module.exports.activate = activate; -module.exports.serve = serve; +module.exports.setFromFilePath = setFromFilePath; +module.exports.get = get; diff --git a/core/server/api/v0.1/settings.js b/core/server/api/v0.1/settings.js index 65d60130e6..4a67e14484 100644 --- a/core/server/api/v0.1/settings.js +++ b/core/server/api/v0.1/settings.js @@ -254,14 +254,14 @@ settings = { upload(options) { return localUtils.handlePermissions('settings', 'edit')(options) .then(() => { - return frontendSettings.dynamicRouting.activate(options.path); + return frontendSettings.dynamicRouting.setFromFilePath(options.path); }); }, download(options) { return localUtils.handlePermissions('settings', 'browse')(options) .then(() => { - return frontendSettings.dynamicRouting.serve(); + return frontendSettings.dynamicRouting.get(); }); } }; diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index 55eef7536a..beeea40639 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -147,7 +147,7 @@ module.exports = { method: 'edit' }, query(frame) { - return frontendSettings.dynamicRouting.activate(frame.file.path); + return frontendSettings.dynamicRouting.setFromFilePath(frame.file.path); } }, @@ -165,7 +165,7 @@ module.exports = { method: 'browse' }, query() { - return frontendSettings.dynamicRouting.serve(); + return frontendSettings.dynamicRouting.get(); } } }; From c7522f896b7a64777302529f8ffd874e0bb2599a Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Fri, 21 Jun 2019 16:34:17 +0200 Subject: [PATCH 9/9] Moved settings dynamicRouting to routing.settings --- core/frontend/services/routing/index.js | 4 ++++ .../{settings/dynamic-routing.js => routing/settings.js} | 0 core/frontend/services/settings/index.js | 5 ----- core/server/api/v0.1/settings.js | 6 +++--- core/server/api/v2/settings.js | 6 +++--- 5 files changed, 10 insertions(+), 11 deletions(-) rename core/frontend/services/{settings/dynamic-routing.js => routing/settings.js} (100%) delete mode 100644 core/frontend/services/settings/index.js diff --git a/core/frontend/services/routing/index.js b/core/frontend/services/routing/index.js index 2a480bc74a..6382b36a8a 100644 --- a/core/frontend/services/routing/index.js +++ b/core/frontend/services/routing/index.js @@ -7,6 +7,10 @@ module.exports = { return require('./registry'); }, + get settings() { + return require('./settings'); + }, + get helpers() { return require('./helpers'); }, diff --git a/core/frontend/services/settings/dynamic-routing.js b/core/frontend/services/routing/settings.js similarity index 100% rename from core/frontend/services/settings/dynamic-routing.js rename to core/frontend/services/routing/settings.js diff --git a/core/frontend/services/settings/index.js b/core/frontend/services/settings/index.js deleted file mode 100644 index ccf6c497aa..0000000000 --- a/core/frontend/services/settings/index.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - get dynamicRouting() { - return require('./dynamic-routing'); - } -}; diff --git a/core/server/api/v0.1/settings.js b/core/server/api/v0.1/settings.js index 4a67e14484..0b5987653a 100644 --- a/core/server/api/v0.1/settings.js +++ b/core/server/api/v0.1/settings.js @@ -5,7 +5,7 @@ const Promise = require('bluebird'), models = require('../../models'), canThis = require('../../services/permissions').canThis, localUtils = require('./utils'), - frontendSettings = require('../../../frontend/services/settings'), + routing = require('../../../frontend/services/routing'), common = require('../../lib/common'), settingsCache = require('../../services/settings/cache'), docName = 'settings'; @@ -254,14 +254,14 @@ settings = { upload(options) { return localUtils.handlePermissions('settings', 'edit')(options) .then(() => { - return frontendSettings.dynamicRouting.setFromFilePath(options.path); + return routing.settings.setFromFilePath(options.path); }); }, download(options) { return localUtils.handlePermissions('settings', 'browse')(options) .then(() => { - return frontendSettings.dynamicRouting.get(); + return routing.settings.get(); }); } }; diff --git a/core/server/api/v2/settings.js b/core/server/api/v2/settings.js index beeea40639..7927a7461e 100644 --- a/core/server/api/v2/settings.js +++ b/core/server/api/v2/settings.js @@ -1,7 +1,7 @@ const Promise = require('bluebird'); const _ = require('lodash'); const models = require('../../models'); -const frontendSettings = require('../../../frontend/services/settings'); +const routing = require('../../../frontend/services/routing'); const common = require('../../lib/common'); const settingsCache = require('../../services/settings/cache'); @@ -147,7 +147,7 @@ module.exports = { method: 'edit' }, query(frame) { - return frontendSettings.dynamicRouting.setFromFilePath(frame.file.path); + return routing.settings.setFromFilePath(frame.file.path); } }, @@ -165,7 +165,7 @@ module.exports = { method: 'browse' }, query() { - return frontendSettings.dynamicRouting.get(); + return routing.settings.get(); } } };