node-enterprise-starter
Version:
<h1 align="center">Node Enterprise Starter</h1>
65 lines (55 loc) • 1.42 kB
text/typescript
/**
* Authentication Routes
* Handles user registration, login, and password management
*/
import express from "express";
import validateRequest from "../../middlewares/validateRequest";
import { AuthController } from "./auth.controller";
import { UserValidation } from "./auth.validation";
import Auth from "../../middlewares/auth";
import { userRole } from "./auth.utils";
// Initialize router
const router = express.Router();
/**
* @route POST /api/auth/register
* @desc Register a new user
* @access Public
*/
router.post(
"/register",
validateRequest(UserValidation.registerUserValidationSchema),
AuthController.register
);
/**
* @route POST /api/auth/login
* @desc Authenticate user & get token
* @access Public
*/
router.post(
"/login",
validateRequest(UserValidation.loginUserValidationSchema),
AuthController.login
);
/**
* @route POST /api/auth/reset-link
* @desc Generate password reset link
* @access Public
*/
router.post("/reset-password", AuthController.resetLink);
/**
* @route POST /api/auth/forgot-password
* @desc Handle forgot password request
* @access Public
*/
router.post("/forgot-password", AuthController.forgetPassword);
/**
* @route POST /api/auth/change-password
* @desc Change user password
* @access Private - User
*/
router.post(
"/change-password",
Auth(userRole.user),
AuthController.changePassword
);
export const AuthRoutes = router;