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

const router = express.Router();

router.get("/public/home", Message.PUBLIC_HOME);
router.get("/public/image/:fileId", Message.PUBLIC_IMAGE);

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

export default router;
