import express from "express";

import {
  createBlog,
  getAllBlog,
  getOneBlog,
  deleteBlog,
  deleteImageFromCloudinary,
  updateBlog,
} from "./BlogController.js";
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";

const router = express.Router();

router
  .route("/create")
  .post(isAuthenticatedUser, authorizeRoles("admin", "Employee"), createBlog);
router.route("/getallblog").get(getAllBlog);
router.route("/getoneblog/:id").get(getOneBlog);
router
  .route("/deleteblog/:id")
  .delete(isAuthenticatedUser, authorizeRoles("admin", "Employee"), deleteBlog);
router
  .route("/deleteImage/jatinMor/Blog/:public_id")
  .delete(
    isAuthenticatedUser,
    authorizeRoles("admin", "Employee"),
    deleteImageFromCloudinary
  );
router
  .route("/updateblog/:id")
  .patch(isAuthenticatedUser, authorizeRoles("admin", "Employee"), updateBlog);
export default router;
