diff --git a/core/server/src/data-access/controllers/admin/comment/validators/get-comments-paginated.ts b/core/server/src/data-access/controllers/admin/comment/validators/get-comments-paginated.ts new file mode 100644 index 00000000..c64fe539 --- /dev/null +++ b/core/server/src/data-access/controllers/admin/comment/validators/get-comments-paginated.ts @@ -0,0 +1,7 @@ +const getCommentsPaginatedRules = { + query: "string", + page: "integer", + entries_per_page: "integer", +}; + +export default getCommentsPaginatedRules; diff --git a/core/server/src/data-access/controllers/admin/comment/validators/index.ts b/core/server/src/data-access/controllers/admin/comment/validators/index.ts index e2e3ea6e..2ae78445 100644 --- a/core/server/src/data-access/controllers/admin/comment/validators/index.ts +++ b/core/server/src/data-access/controllers/admin/comment/validators/index.ts @@ -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 }; diff --git a/core/server/src/routes/admin/comment.ts b/core/server/src/routes/admin/comment.ts index 82e75a0d..bf354e00 100644 --- a/core/server/src/routes/admin/comment.ts +++ b/core/server/src/routes/admin/comment.ts @@ -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),