0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/web/comments/routes.js
Simon Backx e96ff3fa81 Added comments API like and unlike actions
refs https://github.com/TryGhost/Team/issues/1664

- Added comment-like model
- Added like endpoint
- Added unlike endpoint
- Added basic tests for liking and unliking comments
- Added permissions for liking and unliking
- Added migration for permissions
2022-07-12 10:24:02 +02:00

26 lines
990 B
JavaScript

const express = require('../../../shared/express');
const api = require('../../api').endpoints;
const http = require('../../api').shared.http;
const bodyParser = require('body-parser');
const membersService = require('../../../server/services/members');
module.exports = function apiRoutes() {
const router = express.Router('comment api');
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);
router.get('/', http(api.commentsComments.browse));
router.get('/:id', http(api.commentsComments.read));
router.post('/', http(api.commentsComments.add));
router.put('/:id', http(api.commentsComments.edit));
router.delete('/:id', http(api.commentsComments.destroy));
router.post('/:id/like', http(api.commentsComments.like));
router.delete('/:id/like', http(api.commentsComments.unlike));
return router;
};