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.

34 lines
954 B
JavaScript

import express from "express";
const router = express.Router();
import {
createOrder,
getAllOrders,
getUserOrders,
countTotalOrders,
calculateTotalSales,
calcualteTotalSalesByDate,
findOrderById,
markOrderAsPaid,
markOrderAsDelivered,
} from "../controllers/orderController.js";
import { authenticate, authorizeAdmin } from "../middleware/authMiddleWare.js";
router
.route("/")
.post(authenticate, createOrder)
.get(authenticate, authorizeAdmin, getAllOrders);
router.route("/mine").get(authenticate, getUserOrders);
router.route("/total-orders").get(countTotalOrders);
router.route("/total-sales").get(calculateTotalSales);
router.route("/total-sales-by-date").get(calcualteTotalSalesByDate);
router.route("/:id").get(authenticate, findOrderById);
router.route("/:id/pay").put(authenticate, markOrderAsPaid);
router
.route("/:id/deliver")
.put(authenticate, authorizeAdmin, markOrderAsDelivered);
export default router;