const express = require("express"); const auth = require("../controllers/auth.controller"); const user = require("../controllers/user.controller"); const { authenticate } = require("../middleware/auth.middleware"); const validate = require("../middleware/validate.middleware"); const schemas = require("../validation/auth.schemas"); const { sensitiveLimiter } = require("../middleware/rateLimit.middleware"); const router = express.Router(); router.use(sensitiveLimiter); router.post("/register", validate(schemas.register), user.createNewUser); router.post("/login", validate(schemas.login), auth.login); router.post("/req-otp", validate(schemas.login), auth.loginReq); router.post("/verify-otp", validate(schemas.verifyOtp), auth.verifyOtp); router.post("/refresh", validate(schemas.refresh), auth.refreshToken); router.post("/logout", auth.logout); router.post("/logout-all", authenticate, auth.logoutAll); router.post("/forgot-password", validate(schemas.forgot), auth.forgotPassword); router.post("/reset-password", validate(schemas.reset), auth.resetPassword); router.post("/change-password", authenticate, validate(schemas.change), auth.changePassword); router.post("/verify-email", validate(schemas.verifyEmail), auth.verifyEmail); router.post("/resend-verification", validate(schemas.resend), auth.resendVerification); router.post("/google", validate(schemas.oauth), auth.oauth("google")); router.post("/apple", validate(schemas.oauth), auth.oauth("apple")); router.get("/me", authenticate, auth.me); module.exports = router;