import { Router } from 'express';
import { login, getMe } from '../controllers/authController.js';
import { protect } from '../middlewares/auth.js';
import { rateLimit } from '../middlewares/rateLimiter.js';
import { loginValidator } from '../validators/authValidator.js';
import { handleValidation } from '../utils/handleValidation.js';

const router = Router();

router.post('/login', rateLimit({ windowMs: 15 * 60 * 1000, max: 100, message: 'Too many login attempts. Please try again later.' }), loginValidator, handleValidation, login);
router.get('/me', protect, getMe);

export default router;
