UNPKG

@replyke/express

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

31 lines (30 loc) 1.73 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const express_1 = require("express"); const comments_1 = require("../controllers/comments"); const requireUserAuth_1 = __importDefault(require("../../middleware/requireUserAuth")); const router = (0, express_1.Router)(); // Route for posting a new comment on an entity or reply to a comment. router.post("/", requireUserAuth_1.default, comments_1.createComment); // Route to retrieve comments with pagination and sorting options. router.get("/", comments_1.fetchManyComments); // Route to fetch a single comment by foreign id router.get("/by-foreign-id", comments_1.fetchCommentByForeignId); // Route to fetch a single comment by id router.get("/:commentId", comments_1.fetchComment); // Route for updating the content of a comment. router.patch("/:commentId", requireUserAuth_1.default, comments_1.updateComment); // Route for upvoting a comment. router.patch("/:commentId/upvote", requireUserAuth_1.default, comments_1.upvoteComment); // Route for removing a comment upvote. router.patch("/:commentId/remove-upvote", requireUserAuth_1.default, comments_1.removeCommentUpvote); // Route for downvoting a comment. router.patch("/:commentId/downvote", requireUserAuth_1.default, comments_1.downvoteComment); // Route for removing a comment downvote. router.patch("/:commentId/remove-downvote", requireUserAuth_1.default, comments_1.removeCommentDownvote); // Route for deleting a comment and its replies. router.delete("/:commentId", requireUserAuth_1.default, comments_1.deleteComment); exports.default = router;