77 lines
1.3 KiB
JavaScript
77 lines
1.3 KiB
JavaScript
import express from "express";
|
|
import {
|
|
couponPayHistory,
|
|
createCoupon,
|
|
editCoupon,
|
|
getOneCoupon,
|
|
listAffiliateCoupon,
|
|
listAllCoupon,
|
|
suspendCoupon,
|
|
usedCoupon,
|
|
validateCoupon,
|
|
} from "./CouponController.js";
|
|
|
|
import {
|
|
isAuthenticatedUser,
|
|
authorizeRoles,
|
|
} from "../../../middlewares/auth.js";
|
|
|
|
const router = express.Router();
|
|
router.get(
|
|
"/getall",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
listAllCoupon
|
|
);
|
|
router.patch(
|
|
"/create",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
createCoupon
|
|
);
|
|
router.get(
|
|
"/getaffiliate",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
listAffiliateCoupon
|
|
);
|
|
router.patch(
|
|
"/edit/:id",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
editCoupon
|
|
);
|
|
router.get(
|
|
"/getone/:id",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
getOneCoupon
|
|
);
|
|
router.get("/validcoupon/:coupon", validateCoupon);
|
|
router.patch(
|
|
"/suspend",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
suspendCoupon
|
|
);
|
|
router.patch(
|
|
"/paycoupon",
|
|
// isAuthenticatedUser,
|
|
usedCoupon
|
|
);
|
|
/* url:http://localhost:5000/api/v1/coupon/paycoupon
|
|
json structure to paycoupon , Need Header to be auth
|
|
{
|
|
"userId":"random1",
|
|
"orderId":"12s213",
|
|
"coupon_code":"3000MONY"
|
|
}*/
|
|
router.get(
|
|
"/history/:id",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
couponPayHistory
|
|
);
|
|
|
|
export default router;
|