You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
881 B
JavaScript

import express from "express";
import {
createUser,
loginUser,
logoutCurrentUser,
getAllUsers,
getCurrentUserProfile,
updateCurrentUserProfile,
deletUserById,
getUserById,
updateUserById,
} from "../controllers/userController.js";
import { authenticate, authorizeAdmin } from "../middleware/authMiddleWare.js";
const router = express.Router();
router.post("/register", createUser);
router.post("/login", loginUser);
router.post("/logout", logoutCurrentUser);
router
.route("/profile")
.get(authenticate, getCurrentUserProfile)
.put(authenticate, updateCurrentUserProfile);
router.get("/getAllUsers", authenticate, authorizeAdmin, getAllUsers);
router
.route("/:id")
.delete(authenticate, authorizeAdmin, deletUserById)
.get(authenticate, authorizeAdmin, getUserById)
.put(authenticate, authorizeAdmin, updateUserById);
export default router;