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(); } } };