From 608258747a9f125e10c35b7b77977df9574fdba9 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 6 Apr 2022 12:55:50 +0100 Subject: [PATCH] Removed versioned routing configs refs: https://github.com/TryGhost/Toolbox/issues/228 - we are getting rid of the concept of having multiple api versions in a single ghost install - we no longer need versioned routing configs --- .../routing/{config/canary.js => config.js} | 2 - core/frontend/services/routing/config/v2.js | 54 ---------------- core/frontend/services/routing/config/v3.js | 54 ---------------- core/frontend/services/routing/config/v4.js | 61 ------------------- .../services/routing/router-manager.js | 2 +- .../services/route-settings/validate.js | 2 +- .../services/routing/TaxonomyRouter.test.js | 2 +- 7 files changed, 3 insertions(+), 174 deletions(-) rename core/frontend/services/routing/{config/canary.js => config.js} (96%) delete mode 100644 core/frontend/services/routing/config/v2.js delete mode 100644 core/frontend/services/routing/config/v3.js delete mode 100644 core/frontend/services/routing/config/v4.js diff --git a/core/frontend/services/routing/config/canary.js b/core/frontend/services/routing/config.js similarity index 96% rename from core/frontend/services/routing/config/canary.js rename to core/frontend/services/routing/config.js index af6352c504..cd35bd473c 100644 --- a/core/frontend/services/routing/config/canary.js +++ b/core/frontend/services/routing/config.js @@ -1,4 +1,3 @@ -/* eslint-disable */ module.exports.QUERY = { tag: { controller: 'tagsPublic', @@ -58,4 +57,3 @@ module.exports.TAXONOMIES = { resource: 'authors' } }; -/* eslint-enable */ diff --git a/core/frontend/services/routing/config/v2.js b/core/frontend/services/routing/config/v2.js deleted file mode 100644 index f72e92297b..0000000000 --- a/core/frontend/services/routing/config/v2.js +++ /dev/null @@ -1,54 +0,0 @@ -/* eslint-disable */ -module.exports.QUERY = { - tag: { - controller: 'tagsPublic', - type: 'read', - resource: 'tags', - options: { - slug: '%s', - visibility: 'public' - } - }, - author: { - controller: 'authorsPublic', - type: 'read', - resource: 'authors', - options: { - slug: '%s' - } - }, - post: { - controller: 'postsPublic', - type: 'read', - resource: 'posts', - options: { - slug: '%s' - } - }, - page: { - controller: 'pagesPublic', - type: 'read', - resource: 'pages', - options: { - slug: '%s' - } - }, - preview: { - controller: 'preview', - resource: 'preview' - } -}; - -module.exports.TAXONOMIES = { - tag: { - filter: 'tags:\'%s\'+tags.visibility:public', - editRedirect: '#/tags/:slug/', - resource: 'tags' - }, - author: { - filter: 'authors:\'%s\'', - editRedirect: '#/staff/:slug/', - resource: 'authors' - } -}; -/* eslint-enable */ diff --git a/core/frontend/services/routing/config/v3.js b/core/frontend/services/routing/config/v3.js deleted file mode 100644 index f72e92297b..0000000000 --- a/core/frontend/services/routing/config/v3.js +++ /dev/null @@ -1,54 +0,0 @@ -/* eslint-disable */ -module.exports.QUERY = { - tag: { - controller: 'tagsPublic', - type: 'read', - resource: 'tags', - options: { - slug: '%s', - visibility: 'public' - } - }, - author: { - controller: 'authorsPublic', - type: 'read', - resource: 'authors', - options: { - slug: '%s' - } - }, - post: { - controller: 'postsPublic', - type: 'read', - resource: 'posts', - options: { - slug: '%s' - } - }, - page: { - controller: 'pagesPublic', - type: 'read', - resource: 'pages', - options: { - slug: '%s' - } - }, - preview: { - controller: 'preview', - resource: 'preview' - } -}; - -module.exports.TAXONOMIES = { - tag: { - filter: 'tags:\'%s\'+tags.visibility:public', - editRedirect: '#/tags/:slug/', - resource: 'tags' - }, - author: { - filter: 'authors:\'%s\'', - editRedirect: '#/staff/:slug/', - resource: 'authors' - } -}; -/* eslint-enable */ diff --git a/core/frontend/services/routing/config/v4.js b/core/frontend/services/routing/config/v4.js deleted file mode 100644 index af6352c504..0000000000 --- a/core/frontend/services/routing/config/v4.js +++ /dev/null @@ -1,61 +0,0 @@ -/* eslint-disable */ -module.exports.QUERY = { - tag: { - controller: 'tagsPublic', - type: 'read', - resource: 'tags', - options: { - slug: '%s', - visibility: 'public' - } - }, - author: { - controller: 'authorsPublic', - type: 'read', - resource: 'authors', - options: { - slug: '%s' - } - }, - post: { - controller: 'postsPublic', - type: 'read', - resource: 'posts', - options: { - slug: '%s' - } - }, - page: { - controller: 'pagesPublic', - type: 'read', - resource: 'pages', - options: { - slug: '%s' - } - }, - preview: { - controller: 'preview', - resource: 'preview' - }, - email: { - controller: 'emailPost', - resource: 'email_posts', - options: { - slug: '%s' - } - } -}; - -module.exports.TAXONOMIES = { - tag: { - filter: 'tags:\'%s\'+tags.visibility:public', - editRedirect: '#/tags/:slug/', - resource: 'tags' - }, - author: { - filter: 'authors:\'%s\'', - editRedirect: '#/settings/staff/:slug/', - resource: 'authors' - } -}; -/* eslint-enable */ diff --git a/core/frontend/services/routing/router-manager.js b/core/frontend/services/routing/router-manager.js index d695bb75ea..e0e3fbbbdb 100644 --- a/core/frontend/services/routing/router-manager.js +++ b/core/frontend/services/routing/router-manager.js @@ -103,7 +103,7 @@ class RouterManager { */ start(routerSettings) { debug('routing start', routerSettings); - const RESOURCE_CONFIG = require(`./config/canary`); + const RESOURCE_CONFIG = require(`./config`); const unsubscribeRouter = new UnsubscribeRouter(); this.siteRouter.mountRouter(unsubscribeRouter.router()); diff --git a/core/server/services/route-settings/validate.js b/core/server/services/route-settings/validate.js index 8caee90a2f..8d2e71bc15 100644 --- a/core/server/services/route-settings/validate.js +++ b/core/server/services/route-settings/validate.js @@ -429,7 +429,7 @@ module.exports = function validate(object) { } // TODO: extract this config outta here! the config should be passed into this module - RESOURCE_CONFIG = require('../../../frontend/services/routing/config/canary'); + RESOURCE_CONFIG = require('../../../frontend/services/routing/config'); object.routes = _private.validateRoutes(object.routes); object.collections = _private.validateCollections(object.collections); diff --git a/test/unit/frontend/services/routing/TaxonomyRouter.test.js b/test/unit/frontend/services/routing/TaxonomyRouter.test.js index 562a23c107..140e810763 100644 --- a/test/unit/frontend/services/routing/TaxonomyRouter.test.js +++ b/test/unit/frontend/services/routing/TaxonomyRouter.test.js @@ -4,7 +4,7 @@ const settingsCache = require('../../../../../core/shared/settings-cache'); const controllers = require('../../../../../core/frontend/services/routing/controllers'); const TaxonomyRouter = require('../../../../../core/frontend/services/routing/TaxonomyRouter'); -const RESOURCE_CONFIG = require('../../../../../core/frontend/services/routing/config/canary'); +const RESOURCE_CONFIG = require('../../../../../core/frontend/services/routing/config'); describe('UNIT - services/routing/TaxonomyRouter', function () { let req;