From 33f176a9de16eadff074966d0dd3e2802bc26873 Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 23 Feb 2023 11:40:55 +0800 Subject: [PATCH] Cleaned up use of public-resource-repository no issue - The caching has been moved down the layer - the the api-framework's "pipeline", so there's no need to add complexity to post fetching logic with repository pattern. --- ghost/core/core/server/api/endpoints/pages-public.js | 3 +-- ghost/core/core/server/api/endpoints/posts-public.js | 2 +- ghost/core/core/server/services/posts-public/service.js | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ghost/core/core/server/api/endpoints/pages-public.js b/ghost/core/core/server/api/endpoints/pages-public.js index 37adf11e50..a3ffe3a366 100644 --- a/ghost/core/core/server/api/endpoints/pages-public.js +++ b/ghost/core/core/server/api/endpoints/pages-public.js @@ -1,7 +1,6 @@ const tpl = require('@tryghost/tpl'); const errors = require('@tryghost/errors'); const models = require('../../models'); -const postsPublicService = require('../../services/posts-public'); const ALLOWED_INCLUDES = ['tags', 'authors', 'tiers']; @@ -36,7 +35,7 @@ module.exports = { }, permissions: true, query(frame) { - return postsPublicService.api.browse(frame.options); + return models.Post.findPage(frame.options); } }, diff --git a/ghost/core/core/server/api/endpoints/posts-public.js b/ghost/core/core/server/api/endpoints/posts-public.js index a38aeabd73..e63bbef52a 100644 --- a/ghost/core/core/server/api/endpoints/posts-public.js +++ b/ghost/core/core/server/api/endpoints/posts-public.js @@ -37,7 +37,7 @@ module.exports = { }, permissions: true, query(frame) { - return postsPublicService.api.browse(frame.options); + return models.Post.findPage(frame.options); } }, diff --git a/ghost/core/core/server/services/posts-public/service.js b/ghost/core/core/server/services/posts-public/service.js index cc681fa2bf..584f0b5e42 100644 --- a/ghost/core/core/server/services/posts-public/service.js +++ b/ghost/core/core/server/services/posts-public/service.js @@ -6,7 +6,6 @@ class PostsPublicServiceWrapper { } // Wire up all the dependencies - const {Post} = require('../../models'); const adapterManager = require('../adapter-manager'); const config = require('../../../shared/config'); const EventAwareCacheWrapper = require('@tryghost/event-aware-cache-wrapper'); @@ -36,8 +35,7 @@ class PostsPublicServiceWrapper { } this.api = { - cache: cache, - browse: this.postsRepository.getAll.bind(this.postsRepository) + cache: cache }; } }