import express from "express";
import {
	createBlog,
	getBlogs,
	getBlog,
	updateBlog,
	deleteBlog,
	getAllBlogs,
} from "../controllers/blog.controller.js";

import jwtAuthMiddleware from "../middleware/auth.js";

const router = express.Router();

/* PUBLIC */

router.get("/", getBlogs);
router.get("/:id", getBlog);

// Protected

router.get("/admin/all", jwtAuthMiddleware, getAllBlogs);
router.post("/", jwtAuthMiddleware, createBlog);
router.put("/:id", jwtAuthMiddleware, updateBlog);
router.delete("/:id", jwtAuthMiddleware, deleteBlog);

export default router;
