mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Ensured comment counts route doesn't load member (#19762)
refs https://linear.app/tryghost/issue/ENG-672/ The comment counts endpoint does not need member authentication. This saves us a bunch of db queries for each request
This commit is contained in:
parent
7f392c305b
commit
5fae212416
1 changed files with 3 additions and 3 deletions
|
@ -11,15 +11,15 @@ module.exports = function apiRoutes() {
|
||||||
const router = express.Router('comment api');
|
const router = express.Router('comment api');
|
||||||
router.use(bodyParser.json({limit: '50mb'}));
|
router.use(bodyParser.json({limit: '50mb'}));
|
||||||
|
|
||||||
// Global handling for member session, ensures a member is logged in to the frontend
|
|
||||||
router.use(membersService.middleware.loadMemberSession);
|
|
||||||
|
|
||||||
const countsCache = shared.middleware.cacheControl(
|
const countsCache = shared.middleware.cacheControl(
|
||||||
'public',
|
'public',
|
||||||
{maxAge: config.get('caching:commentsCountAPI:maxAge')}
|
{maxAge: config.get('caching:commentsCountAPI:maxAge')}
|
||||||
);
|
);
|
||||||
router.get('/counts', countsCache, http(api.commentsMembers.counts));
|
router.get('/counts', countsCache, http(api.commentsMembers.counts));
|
||||||
|
|
||||||
|
// Authenticated Routes
|
||||||
|
router.use(membersService.middleware.loadMemberSession);
|
||||||
|
|
||||||
router.get('/', http(api.commentsMembers.browse));
|
router.get('/', http(api.commentsMembers.browse));
|
||||||
router.get('/:id', http(api.commentsMembers.read));
|
router.get('/:id', http(api.commentsMembers.read));
|
||||||
router.post('/', http(api.commentsMembers.add));
|
router.post('/', http(api.commentsMembers.add));
|
||||||
|
|
Loading…
Add table
Reference in a new issue