Skip to content

Commit

Permalink
get comments paginated route
Browse files Browse the repository at this point in the history
  • Loading branch information
huytran17 committed Aug 29, 2024
1 parent d67f8d0 commit d119a6e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const getCommentsPaginatedRules = {
query: "string",
page: "integer",
entries_per_page: "integer",
};

export default getCommentsPaginatedRules;
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import getCommentsPaginatedRules from "./get-comments-paginated";
import hardDeleteCommentRules from "./hard-delete-comment";

export default Object.freeze({
hardDeleteCommentRules,
getCommentsPaginatedRules,
});

export { hardDeleteCommentRules };
export { getCommentsPaginatedRules, hardDeleteCommentRules };
13 changes: 12 additions & 1 deletion core/server/src/routes/admin/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ import makeValidator from "../../config/middlewares/validator";
import { AuthorizationRole } from "../../constants/authorization-role";
import {
getCommentsController,
getCommentsPaginatedController,
hardDeleteCommentController,
} from "../../data-access/controllers/admin/comment";
import { hardDeleteCommentRules } from "../../data-access/controllers/admin/comment/validators";
import {
getCommentsPaginatedRules,
hardDeleteCommentRules,
} from "../../data-access/controllers/admin/comment/validators";

const commentRouter = Router();

commentRouter.delete(
"/all-paginated",
makeAuthorization(AuthorizationRole.OWNER_AND_COLLABORATOR),
makeValidator(getCommentsPaginatedRules),
makeExpressCallback(getCommentsPaginatedController)
);

commentRouter.delete(
"/hard-delete/:_id",
makeAuthorization(AuthorizationRole.OWNER_AND_COLLABORATOR),
Expand Down

0 comments on commit d119a6e

Please sign in to comment.