This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const couponCodeDiscount = require("./routes/CouponCode.Routes"); | |
| app.use("/api", couponCodeDiscount); | |
| // checking coupon code expiration time valid or not to reduce server load | |
| const checkExpirationTime = () => { | |
| CouponCodeDiscount.find({}) | |
| .exec() | |
| .then((Coupon) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require("express"); | |
| const router = express.Router(); | |
| const { | |
| addCouponCodeDiscount, | |
| } = require("../controllers/CouponCode"); | |
| router.post( | |
| "/product/couponCode-discount", | |
| addCouponCodeDiscount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mongoose = require("mongoose"); | |
| const Schema = mongoose.Schema; | |
| const moment = require("moment"); | |
| // creating objectSchema | |
| const couponCodeSchema = new Schema({ | |
| couponCodeName: { | |
| type: String, | |
| min: 5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const CouponCodeDiscount = require("../models/CouponCode.Models"); | |
| const Product = require("../models/Product.Models"); | |
| const moment = require("moment"); | |
| exports.addCouponCodeDiscount = async(req, res) => { | |
| const { | |
| couponCodeName, | |
| productId, | |
| discount, | |
| discountStatus, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const CouponCodeDiscount = require("../models/CouponCode.Models"); | |
| const Product = require("../models/Product.Models"); | |
| const moment = require("moment"); | |
| exports.addCouponCodeDiscount = async(req, res) => { | |
| const { | |
| couponCodeName, | |
| productId, | |
| discount, | |
| discountStatus, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mongoose = require("mongoose"); | |
| const moment = require("moment"); | |
| const Schema = mongoose.Schema; | |
| const productSchema = new Schema({ | |
| name: { | |
| type: String, | |
| required: true, | |
| trim: true, | |
| }, |