|
|
|
const express = require("express");
|
|
|
|
const userControllers = require("../controllers/userControllers.js");
|
|
|
|
const auth = require("../auth.js");
|
|
|
|
const {verify, verifyAdmin} = auth;
|
|
|
|
|
|
|
|
// Router
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
|
|
|
|
// check email route
|
|
|
|
router.get(`/checkEmail`, userControllers.checkEmailExists);
|
|
|
|
|
|
|
|
// register user route
|
|
|
|
router.post(`/register`, userControllers.checkEmailExists, userControllers.registerUser);
|
|
|
|
|
|
|
|
// authentication route.
|
|
|
|
router.post(`/login`, userControllers.loginUser);
|
|
|
|
|
|
|
|
// get current user details route.
|
|
|
|
router.get(`/details`, verify, userControllers.getCurrentUserDetails);
|
|
|
|
|
|
|
|
// set user to admin route.
|
|
|
|
router.put(`/set-admin`, verify, verifyAdmin, userControllers.setUserAsAdmin);
|
|
|
|
|
|
|
|
// get current user orders route.
|
|
|
|
router.get(`/orders`, verify, userControllers.getCurrentUserOrders);
|
|
|
|
|
|
|
|
// retrieve all orders route (admin only).
|
|
|
|
router.get(`/get-all-orders`, verify, verifyAdmin, userControllers.getAllOrders);
|
|
|
|
|
|
|
|
// Route for resetting password
|
|
|
|
router.post(`/reset-password`, verify, userControllers.resetPassword);
|
|
|
|
|
|
|
|
// Route for updating profile
|
|
|
|
router.put('/update-profile', verify, userControllers.updateProfile);
|
|
|
|
|
|
|
|
// Route for getting user name by id
|
|
|
|
router.post('/getUserName', userControllers.getUserName);
|
|
|
|
|
|
|
|
module.exports = router;
|