import express from "express";
import {
  register,
  verifyOTP,
  login,
  logout,
  getUser,
  forgotPassword,
  resetPassword,
  getUsersByRole,
  updateUser,
  deleteUser,
  getAllUsers,
} from "../controllers/userController.js";
import { isAuthenticated } from "../middlewares/auth.js";
import upload from "../middlewares/upload.js";

const router = express.Router();

router.post("/register", register);

router.post("/verify-otp", verifyOTP);

router.post("/login", login);

router.get("/logout", isAuthenticated, logout);
router.get("/all", getAllUsers);
router.get("/", getUsersByRole);

router.get("/me", isAuthenticated, getUser);

router.post("/password/forgotpassword", forgotPassword);

router.put("/password/reset/:token", resetPassword);

router.put("/:id", upload.single("file"), updateUser);

router.delete("/:id", deleteUser);

export default router;
