"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const auth_controller_1 = require("../controllers/auth.controller");
const auth_middleware_1 = require("../middleware/auth.middleware");
const rateLimiter_middleware_1 = require("../middleware/rateLimiter.middleware");
const validate_middleware_1 = require("../middleware/validate.middleware");
const auth_validator_1 = require("../validators/auth.validator");
const router = (0, express_1.Router)();
// Public Authentication Endpoints
router.post('/register', rateLimiter_middleware_1.authRateLimiter, (0, validate_middleware_1.validateRequest)(auth_validator_1.registerSchema), auth_controller_1.register);
router.post('/login', rateLimiter_middleware_1.authRateLimiter, (0, validate_middleware_1.validateRequest)(auth_validator_1.loginSchema), auth_controller_1.login);
router.post('/admin/login', rateLimiter_middleware_1.authRateLimiter, (0, validate_middleware_1.validateRequest)(auth_validator_1.adminLoginSchema), auth_controller_1.adminLogin);
router.post('/google', rateLimiter_middleware_1.authRateLimiter, (0, validate_middleware_1.validateRequest)(auth_validator_1.googleAuthSchema), auth_controller_1.googleLogin);
// OTP & Verification Endpoints
router.post('/send-otp', rateLimiter_middleware_1.otpRateLimiter, auth_controller_1.sendVerificationOtp);
router.post('/verify-otp', (0, validate_middleware_1.validateRequest)(auth_validator_1.verifyOtpSchema), auth_controller_1.verifyOtp);
// Password Recovery Endpoints
router.post('/forgot-password', rateLimiter_middleware_1.authRateLimiter, (0, validate_middleware_1.validateRequest)(auth_validator_1.forgotPasswordSchema), auth_controller_1.forgotPassword);
router.post('/reset-password', rateLimiter_middleware_1.authRateLimiter, (0, validate_middleware_1.validateRequest)(auth_validator_1.resetPasswordSchema), auth_controller_1.resetPassword);
// Token Refresh
router.post('/refresh', (0, validate_middleware_1.validateRequest)(auth_validator_1.refreshTokenSchema), auth_controller_1.refreshTokenHandler);
// Protected Session & Logout Endpoints
router.get('/sessions', auth_middleware_1.authenticateJWT, auth_controller_1.getActiveSessions);
router.put('/profile', auth_middleware_1.authenticateJWT, (0, validate_middleware_1.validateRequest)(auth_validator_1.updateProfileSchema), auth_controller_1.updateProfile);
router.post('/logout', auth_middleware_1.authenticateJWT, auth_controller_1.logout);
router.post('/logout-all', auth_middleware_1.authenticateJWT, auth_controller_1.logoutAllDevices);
exports.default = router;
//# sourceMappingURL=auth.routes.js.map