From 5eaa1938c7e17412ef63897916452b2e5392e6a0 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 6 Apr 2022 13:03:22 +0100 Subject: [PATCH] Removed versioned confg from URL Service refs: https://github.com/TryGhost/Toolbox/issues/228 refs: https://github.com/TryGhost/Toolbox/issues/229 - we are getting rid of the concept of having multiple api versions in a single ghost install - this means the url service doesn't need to be versioned any more --- core/frontend/web/routes.js | 2 +- core/server/services/url/Resources.js | 2 +- .../url/{configs/canary.js => config.js} | 0 core/server/services/url/configs/v2.js | 141 ----------------- core/server/services/url/configs/v3.js | 141 ----------------- core/server/services/url/configs/v4.js | 143 ------------------ 6 files changed, 2 insertions(+), 427 deletions(-) rename core/server/services/url/{configs/canary.js => config.js} (100%) delete mode 100644 core/server/services/url/configs/v2.js delete mode 100644 core/server/services/url/configs/v3.js delete mode 100644 core/server/services/url/configs/v4.js diff --git a/core/frontend/web/routes.js b/core/frontend/web/routes.js index 2351946dc5..1c8690a43f 100644 --- a/core/frontend/web/routes.js +++ b/core/frontend/web/routes.js @@ -1,4 +1,4 @@ -const debug = require('@tryghost/debug')('routing'); +const debug = require('@tryghost/debug')('frontend:routes'); const routing = require('../services/routing'); const urlService = require('../../server/services/url'); diff --git a/core/server/services/url/Resources.js b/core/server/services/url/Resources.js index f37b0d5c03..4c1da8041d 100644 --- a/core/server/services/url/Resources.js +++ b/core/server/services/url/Resources.js @@ -59,7 +59,7 @@ class Resources { return; } - this.resourcesConfig = require('./configs/canary'); + this.resourcesConfig = require('./config'); } /** diff --git a/core/server/services/url/configs/canary.js b/core/server/services/url/config.js similarity index 100% rename from core/server/services/url/configs/canary.js rename to core/server/services/url/config.js diff --git a/core/server/services/url/configs/v2.js b/core/server/services/url/configs/v2.js deleted file mode 100644 index 3d3eaa2112..0000000000 --- a/core/server/services/url/configs/v2.js +++ /dev/null @@ -1,141 +0,0 @@ -/* - * These are the default resources and filters. - * They contain minimum filters for public accessibility of resources. - */ - -module.exports = [ - { - type: 'posts', - modelOptions: { - modelName: 'Post', - filter: 'status:published+type:post', - exclude: [ - 'title', - 'mobiledoc', - 'html', - 'plaintext', - // @TODO: https://github.com/TryGhost/Ghost/issues/10335 - // 'page', - 'status', - 'amp', - 'codeinjection_head', - 'codeinjection_foot', - 'meta_title', - 'meta_description', - 'custom_excerpt', - 'og_image', - 'og_title', - 'og_description', - 'twitter_image', - 'twitter_title', - 'twitter_description', - 'custom_template', - 'locale' - ], - withRelated: ['tags', 'authors'], - withRelatedPrimary: { - primary_tag: 'tags', - primary_author: 'authors' - }, - withRelatedFields: { - tags: ['tags.id', 'tags.slug'], - authors: ['users.id', 'users.slug'] - } - }, - events: { - add: 'post.published', - update: 'post.published.edited', - remove: 'post.unpublished' - } - }, - { - type: 'pages', - modelOptions: { - modelName: 'Post', - exclude: [ - 'title', - 'mobiledoc', - 'html', - 'plaintext', - // @TODO: https://github.com/TryGhost/Ghost/issues/10335 - // 'page', - // 'status', - 'amp', - 'codeinjection_head', - 'codeinjection_foot', - 'meta_title', - 'meta_description', - 'custom_excerpt', - 'og_image', - 'og_title', - 'og_description', - 'twitter_image', - 'twitter_title', - 'twitter_description', - 'custom_template', - 'locale', - 'tags', - 'authors', - 'primary_tag', - 'primary_author' - ], - filter: 'status:published+type:page' - }, - events: { - add: 'page.published', - update: 'page.published.edited', - remove: 'page.unpublished' - } - }, - { - type: 'tags', - keep: ['id', 'slug'], - modelOptions: { - modelName: 'Tag', - exclude: [ - 'description', - 'meta_title', - 'meta_description', - 'parent_id' - ], - filter: 'visibility:public', - shouldHavePosts: { - joinTo: 'tag_id', - joinTable: 'posts_tags' - } - }, - events: { - add: 'tag.added', - update: ['tag.edited', 'tag.attached', 'tag.detached'], - remove: 'tag.deleted' - } - }, - { - type: 'authors', - modelOptions: { - modelName: 'User', - exclude: [ - 'bio', - 'website', - 'location', - 'facebook', - 'twitter', - 'locale', - 'accessibility', - 'meta_title', - 'meta_description', - 'tour' - ], - filter: 'visibility:public', - shouldHavePosts: { - joinTo: 'author_id', - joinTable: 'posts_authors' - } - }, - events: { - add: 'user.activated', - update: ['user.activated.edited', 'user.attached', 'user.detached'], - remove: 'user.deleted' - } - } -]; diff --git a/core/server/services/url/configs/v3.js b/core/server/services/url/configs/v3.js deleted file mode 100644 index 3d3eaa2112..0000000000 --- a/core/server/services/url/configs/v3.js +++ /dev/null @@ -1,141 +0,0 @@ -/* - * These are the default resources and filters. - * They contain minimum filters for public accessibility of resources. - */ - -module.exports = [ - { - type: 'posts', - modelOptions: { - modelName: 'Post', - filter: 'status:published+type:post', - exclude: [ - 'title', - 'mobiledoc', - 'html', - 'plaintext', - // @TODO: https://github.com/TryGhost/Ghost/issues/10335 - // 'page', - 'status', - 'amp', - 'codeinjection_head', - 'codeinjection_foot', - 'meta_title', - 'meta_description', - 'custom_excerpt', - 'og_image', - 'og_title', - 'og_description', - 'twitter_image', - 'twitter_title', - 'twitter_description', - 'custom_template', - 'locale' - ], - withRelated: ['tags', 'authors'], - withRelatedPrimary: { - primary_tag: 'tags', - primary_author: 'authors' - }, - withRelatedFields: { - tags: ['tags.id', 'tags.slug'], - authors: ['users.id', 'users.slug'] - } - }, - events: { - add: 'post.published', - update: 'post.published.edited', - remove: 'post.unpublished' - } - }, - { - type: 'pages', - modelOptions: { - modelName: 'Post', - exclude: [ - 'title', - 'mobiledoc', - 'html', - 'plaintext', - // @TODO: https://github.com/TryGhost/Ghost/issues/10335 - // 'page', - // 'status', - 'amp', - 'codeinjection_head', - 'codeinjection_foot', - 'meta_title', - 'meta_description', - 'custom_excerpt', - 'og_image', - 'og_title', - 'og_description', - 'twitter_image', - 'twitter_title', - 'twitter_description', - 'custom_template', - 'locale', - 'tags', - 'authors', - 'primary_tag', - 'primary_author' - ], - filter: 'status:published+type:page' - }, - events: { - add: 'page.published', - update: 'page.published.edited', - remove: 'page.unpublished' - } - }, - { - type: 'tags', - keep: ['id', 'slug'], - modelOptions: { - modelName: 'Tag', - exclude: [ - 'description', - 'meta_title', - 'meta_description', - 'parent_id' - ], - filter: 'visibility:public', - shouldHavePosts: { - joinTo: 'tag_id', - joinTable: 'posts_tags' - } - }, - events: { - add: 'tag.added', - update: ['tag.edited', 'tag.attached', 'tag.detached'], - remove: 'tag.deleted' - } - }, - { - type: 'authors', - modelOptions: { - modelName: 'User', - exclude: [ - 'bio', - 'website', - 'location', - 'facebook', - 'twitter', - 'locale', - 'accessibility', - 'meta_title', - 'meta_description', - 'tour' - ], - filter: 'visibility:public', - shouldHavePosts: { - joinTo: 'author_id', - joinTable: 'posts_authors' - } - }, - events: { - add: 'user.activated', - update: ['user.activated.edited', 'user.attached', 'user.detached'], - remove: 'user.deleted' - } - } -]; diff --git a/core/server/services/url/configs/v4.js b/core/server/services/url/configs/v4.js deleted file mode 100644 index dbb0841b66..0000000000 --- a/core/server/services/url/configs/v4.js +++ /dev/null @@ -1,143 +0,0 @@ -/* - * These are the default resources and filters. - * They contain minimum filters for public accessibility of resources. - */ - -// @TODO: keep this similar to ./canary.js until the v5 release - -module.exports = [ - { - type: 'posts', - modelOptions: { - modelName: 'Post', - filter: 'status:published+type:post', - exclude: [ - 'title', - 'mobiledoc', - 'html', - 'plaintext', - // @TODO: https://github.com/TryGhost/Ghost/issues/10335 - // 'page', - 'status', - 'amp', - 'codeinjection_head', - 'codeinjection_foot', - 'meta_title', - 'meta_description', - 'custom_excerpt', - 'og_image', - 'og_title', - 'og_description', - 'twitter_image', - 'twitter_title', - 'twitter_description', - 'custom_template', - 'locale' - ], - withRelated: ['tags', 'authors'], - withRelatedPrimary: { - primary_tag: 'tags', - primary_author: 'authors' - }, - withRelatedFields: { - tags: ['tags.id', 'tags.slug'], - authors: ['users.id', 'users.slug'] - } - }, - events: { - add: 'post.published', - update: 'post.published.edited', - remove: 'post.unpublished' - } - }, - { - type: 'pages', - modelOptions: { - modelName: 'Post', - exclude: [ - 'title', - 'mobiledoc', - 'html', - 'plaintext', - // @TODO: https://github.com/TryGhost/Ghost/issues/10335 - // 'page', - // 'status', - 'amp', - 'codeinjection_head', - 'codeinjection_foot', - 'meta_title', - 'meta_description', - 'custom_excerpt', - 'og_image', - 'og_title', - 'og_description', - 'twitter_image', - 'twitter_title', - 'twitter_description', - 'custom_template', - 'locale', - 'tags', - 'authors', - 'primary_tag', - 'primary_author' - ], - filter: 'status:published+type:page' - }, - events: { - add: 'page.published', - update: 'page.published.edited', - remove: 'page.unpublished' - } - }, - { - type: 'tags', - keep: ['id', 'slug'], - modelOptions: { - modelName: 'Tag', - exclude: [ - 'description', - 'meta_title', - 'meta_description', - 'parent_id' - ], - filter: 'visibility:public', - shouldHavePosts: { - joinTo: 'tag_id', - joinTable: 'posts_tags' - } - }, - events: { - add: 'tag.added', - update: ['tag.edited', 'tag.attached', 'tag.detached'], - remove: 'tag.deleted' - } - }, - { - type: 'authors', - modelOptions: { - modelName: 'User', - exclude: [ - 'bio', - 'website', - 'location', - 'facebook', - 'twitter', - 'locale', - 'accessibility', - 'meta_title', - 'meta_description', - 'tour' - ], - filter: 'visibility:public', - shouldHavePosts: { - joinTo: 'author_id', - joinTable: 'posts_authors' - } - }, - events: { - add: 'user.activated', - update: ['user.activated.edited', 'user.attached', 'user.detached'], - remove: 'user.deleted' - } - } -];