"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const authController_js_1 = require("../controllers/authController.js");
const authMiddleware_js_1 = require("../middleware/authMiddleware.js");
const rateLimit_js_1 = require("../middleware/rateLimit.js");
const validateRequest_js_1 = require("../middleware/validateRequest.js");
const asyncHandler_js_1 = require("../utils/asyncHandler.js");
const authValidators_js_1 = require("../validators/authValidators.js");
const router = (0, express_1.Router)();
const otpLimiter = (0, rateLimit_js_1.rateLimit)({
    windowMs: 15 * 60 * 1000,
    max: 5,
    keyPrefix: "otp",
});
const loginLimiter = (0, rateLimit_js_1.rateLimit)({
    windowMs: 15 * 60 * 1000,
    max: 10,
    keyPrefix: "login",
});
router.post("/customer/request-otp", otpLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.customerRequestOtpSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.requestCustomerOtp));
router.post("/customer/verify-otp", otpLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.customerVerifyOtpSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.verifyCustomerOtp));
router.post("/staff/register", authMiddleware_js_1.optionalAuth, loginLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.staffRegisterSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.registerStaff));
router.post("/staff/login", loginLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.staffLoginSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.loginStaff));
router.post("/staff/request-otp", otpLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.staffRequestOtpSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.requestStaffOtp));
router.post("/staff/verify-otp", otpLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.staffVerifyOtpSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.verifyStaffOtp));
router.post("/refresh", loginLimiter, (0, validateRequest_js_1.validateBody)(authValidators_js_1.refreshTokenSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.refreshAuthToken));
router.post("/logout", (0, validateRequest_js_1.validateBody)(authValidators_js_1.logoutSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.logout));
router.post("/change-password", authMiddleware_js_1.requireAuth, (0, validateRequest_js_1.validateBody)(authValidators_js_1.changePasswordSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.changePassword));
router.post("/logout-all", authMiddleware_js_1.requireAuth, (0, asyncHandler_js_1.asyncHandler)(authController_js_1.logoutAll));
router.patch("/customer/profile", authMiddleware_js_1.requireAuth, (0, validateRequest_js_1.validateBody)(authValidators_js_1.customerUpdateProfileSchema), (0, asyncHandler_js_1.asyncHandler)(authController_js_1.updateCustomerProfile));
router.get("/me", authMiddleware_js_1.requireAuth, (0, asyncHandler_js_1.asyncHandler)(authController_js_1.getCurrentUser));
exports.default = router;
//# sourceMappingURL=authRoutes.js.map