// backend/routes/userRoutes.js
import express from 'express';
import { getUserById, getCurrentUser, getUserByEmail, getAllUsers } from '../controllers/userController.js';
import authMiddleware from '../middlewares/authMiddleware.js';

const router = express.Router();

// Route to get all users (admin access)
router.get('/', authMiddleware, getAllUsers);

// Route to get user by email (protected route)
router.get('/email/:email', authMiddleware, getUserByEmail);

// Route to get current user
router.get('/me', authMiddleware, (req, res, next) => {
//  console.log('Route /api/users/me is hit');
  next();
}, getCurrentUser);

// Route to get user by ID (protected route)
router.get('/:id', authMiddleware, getUserById);

export default router;

