const express = require("express");
const router = express.Router();
const {
  ambilSemua,
  detailProduk,
  buatProduk,
  ubahStok,
  hapusData,
} = require("./controller.js");

const { verifyToken, isAdmin } = require("../Middleware/token.js");

// Publik (Siapa saja boleh lihat)
router.get("/", ambilSemua);
router.get("/detail/:id", detailProduk);

// Private (Harus Login & Harus Admin)
router.post("/tambah", verifyToken, isAdmin, buatProduk);
router.put("/update/:id", verifyToken, isAdmin, ubahStok);
router.delete("/delete/:id", verifyToken, isAdmin, hapusData);

module.exports = router;
