You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
966 B
JavaScript
31 lines
966 B
JavaScript
11 months ago
|
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);
|
||
|
|
||
|
module.exports = router;
|