import express from "express";
import { News } from "$controllers/index.js";
import { checkPermission, jwt } from "$middlewares/index.js";

const router = express.Router();

router.get("/public", News.PUBLIC_ALL);
router.get("/public/cover/:fileId", News.PUBLIC_COVER);
router.get("/public/:category/:slug/:seoTitle", News.PUBLIC_SINGLE);
router.get("/public/:category/:slug", News.PUBLIC_SINGLE);

router.get("/", jwt, checkPermission("news:view"), News.ALL);
router.get("/:id", jwt, checkPermission("news:view"), News.SINGLE);
router.post("/", jwt, checkPermission("news:create"), News.CREATE);
router.put("/:id", jwt, checkPermission("news:update"), News.UPDATE);
router.delete("/:id", jwt, checkPermission("news:delete"), News.DELETE);

export default router;
