From 47267426738a52413652a598a5fbb163f433c73e Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Mon, 12 Sep 2022 14:58:10 -0400 Subject: [PATCH] Renamed `redirects` to `custom-redirects` We're going to be adding more redirection logic into Ghost and it's going to get confusing if we have names this generic. This makes it clear which feature this service is related to. Ideally in the future we can combine all of these into one redirects service, but for now we will be running a specific service per feature --- ghost/core/core/boot.js | 2 +- ghost/core/core/frontend/web/site.js | 2 +- ghost/core/core/server/api/endpoints/redirects.js | 10 +++++----- .../services/{redirects => custom-redirects}/api.js | 0 .../services/{redirects => custom-redirects}/index.js | 0 .../services/{redirects => custom-redirects}/utils.js | 0 .../{redirects => custom-redirects}/validation.js | 0 .../{redirects => custom-redirects}/api.test.js | 2 +- .../{redirects => custom-redirects}/validation.test.js | 2 +- ghost/core/test/utils/e2e-utils.js | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) rename ghost/core/core/server/services/{redirects => custom-redirects}/api.js (100%) rename ghost/core/core/server/services/{redirects => custom-redirects}/index.js (100%) rename ghost/core/core/server/services/{redirects => custom-redirects}/utils.js (100%) rename ghost/core/core/server/services/{redirects => custom-redirects}/validation.js (100%) rename ghost/core/test/unit/server/services/{redirects => custom-redirects}/api.test.js (99%) rename ghost/core/test/unit/server/services/{redirects => custom-redirects}/validation.test.js (98%) diff --git a/ghost/core/core/boot.js b/ghost/core/core/boot.js index d87112e5e5..ae51499a27 100644 --- a/ghost/core/core/boot.js +++ b/ghost/core/core/boot.js @@ -155,7 +155,7 @@ async function initServicesForFrontend({bootLogger}) { debug('End: Routing Settings'); debug('Begin: Redirects'); - const customRedirects = require('./server/services/redirects'); + const customRedirects = require('./server/services/custom-redirects'); await customRedirects.init(), debug('End: Redirects'); diff --git a/ghost/core/core/frontend/web/site.js b/ghost/core/core/frontend/web/site.js index 541603e60a..f198c22eb9 100644 --- a/ghost/core/core/frontend/web/site.js +++ b/ghost/core/core/frontend/web/site.js @@ -14,7 +14,7 @@ const themeEngine = require('../services/theme-engine'); const themeMiddleware = themeEngine.middleware; const membersService = require('../../server/services/members'); const offersService = require('../../server/services/offers'); -const customRedirects = require('../../server/services/redirects'); +const customRedirects = require('../../server/services/custom-redirects'); const siteRoutes = require('./routes'); const shared = require('../../server/web/shared'); const errorHandler = require('@tryghost/mw-error-handler'); diff --git a/ghost/core/core/server/api/endpoints/redirects.js b/ghost/core/core/server/api/endpoints/redirects.js index 09295969b0..c80898d1a5 100644 --- a/ghost/core/core/server/api/endpoints/redirects.js +++ b/ghost/core/core/server/api/endpoints/redirects.js @@ -1,6 +1,6 @@ const path = require('path'); -const redirects = require('../../services/redirects'); +const customRedirects = require('../../services/custom-redirects'); module.exports = { docName: 'redirects', @@ -10,7 +10,7 @@ module.exports = { disposition: { type: 'file', value() { - return redirects.api.getRedirectsFilePath() + return customRedirects.api.getRedirectsFilePath() .then((filePath) => { // @deprecated: .json was deprecated in v4.0 but is still the default for backwards compat return filePath === null || path.extname(filePath) === '.json' @@ -23,13 +23,13 @@ module.exports = { permissions: true, response: { async format() { - const filePath = await redirects.api.getRedirectsFilePath(); + const filePath = await customRedirects.api.getRedirectsFilePath(); return filePath === null || path.extname(filePath) === '.json' ? 'json' : 'plain'; } }, query() { - return redirects.api.get(); + return customRedirects.api.get(); } }, @@ -39,7 +39,7 @@ module.exports = { cacheInvalidate: true }, query(frame) { - return redirects.api.setFromFilePath(frame.file.path, frame.file.ext); + return customRedirects.api.setFromFilePath(frame.file.path, frame.file.ext); } } }; diff --git a/ghost/core/core/server/services/redirects/api.js b/ghost/core/core/server/services/custom-redirects/api.js similarity index 100% rename from ghost/core/core/server/services/redirects/api.js rename to ghost/core/core/server/services/custom-redirects/api.js diff --git a/ghost/core/core/server/services/redirects/index.js b/ghost/core/core/server/services/custom-redirects/index.js similarity index 100% rename from ghost/core/core/server/services/redirects/index.js rename to ghost/core/core/server/services/custom-redirects/index.js diff --git a/ghost/core/core/server/services/redirects/utils.js b/ghost/core/core/server/services/custom-redirects/utils.js similarity index 100% rename from ghost/core/core/server/services/redirects/utils.js rename to ghost/core/core/server/services/custom-redirects/utils.js diff --git a/ghost/core/core/server/services/redirects/validation.js b/ghost/core/core/server/services/custom-redirects/validation.js similarity index 100% rename from ghost/core/core/server/services/redirects/validation.js rename to ghost/core/core/server/services/custom-redirects/validation.js diff --git a/ghost/core/test/unit/server/services/redirects/api.test.js b/ghost/core/test/unit/server/services/custom-redirects/api.test.js similarity index 99% rename from ghost/core/test/unit/server/services/redirects/api.test.js rename to ghost/core/test/unit/server/services/custom-redirects/api.test.js index ef0d75a983..6e01bc6c15 100644 --- a/ghost/core/test/unit/server/services/redirects/api.test.js +++ b/ghost/core/test/unit/server/services/custom-redirects/api.test.js @@ -4,7 +4,7 @@ const path = require('path'); const fs = require('fs-extra'); const logging = require('@tryghost/logging'); -const CustomRedirectsAPI = require('../../../../../core/server/services/redirects/api'); +const CustomRedirectsAPI = require('../../../../../core/server/services/custom-redirects/api'); describe('UNIT: redirects CustomRedirectsAPI class', function () { let customRedirectsAPI; diff --git a/ghost/core/test/unit/server/services/redirects/validation.test.js b/ghost/core/test/unit/server/services/custom-redirects/validation.test.js similarity index 98% rename from ghost/core/test/unit/server/services/redirects/validation.test.js rename to ghost/core/test/unit/server/services/custom-redirects/validation.test.js index 335e8a336b..a3a6f35b7a 100644 --- a/ghost/core/test/unit/server/services/redirects/validation.test.js +++ b/ghost/core/test/unit/server/services/custom-redirects/validation.test.js @@ -1,6 +1,6 @@ const should = require('should'); -const {validate} = require('../../../../../core/server/services/redirects/validation'); +const {validate} = require('../../../../../core/server/services/custom-redirects/validation'); describe('UNIT: custom redirects validation', function () { it('passes validation for a valid redirects config', function () { diff --git a/ghost/core/test/utils/e2e-utils.js b/ghost/core/test/utils/e2e-utils.js index 5f0c1b20d7..8e09c72f50 100644 --- a/ghost/core/test/utils/e2e-utils.js +++ b/ghost/core/test/utils/e2e-utils.js @@ -19,7 +19,7 @@ const settingsService = require('../../core/server/services/settings/settings-se const routeSettingsService = require('../../core/server/services/route-settings'); const themeService = require('../../core/server/services/themes'); const limits = require('../../core/server/services/limits'); -const customRedirectsService = require('../../core/server/services/redirects'); +const customRedirectsService = require('../../core/server/services/custom-redirects'); // Other Test Utilities const configUtils = require('./configUtils');