-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
753 additions
and
175 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MONGODB_URI = mongodb+srv://amarjha880:[email protected]/E-commerce?retryWrites=true&w=majority&appName=E-commerce | ||
|
||
|
||
TOKEN_SECRET_KEY = "Sjhhhhhhgyuuyfdstgfvuyuy6876yuggbfdtrde56essGFHTFJGUYF4" | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.env | ||
# .env | ||
node_modules |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ProductModel from "../../models/productModel.js"; | ||
|
||
const searchProduct = async (req, res) => { | ||
try { | ||
|
||
const query = req.query.q; | ||
const regex = RegExp(query,'i','g'); | ||
const searchedProduct = await ProductModel.find({ | ||
'$or':[ | ||
{ | ||
brandName: regex | ||
}, | ||
{ | ||
category: regex | ||
}, | ||
{ | ||
productName: regex | ||
}, | ||
] | ||
}) | ||
|
||
res.status(200).json({ | ||
message: "searchedProduct list", | ||
data: searchedProduct, | ||
}); | ||
} catch (error) { | ||
res.status(400).json({ | ||
err: error.message, | ||
}); | ||
} | ||
}; | ||
export default searchProduct; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import addToCartModel from "../../models/cartProductModel.js"; | ||
|
||
const deleteAddToCartProduct = async (req, res) => { | ||
try { | ||
|
||
const AddToCartProductId = req.body._id; | ||
|
||
const deleteProduct = await addToCartModel.deleteOne({_id : AddToCartProductId}); | ||
res.status(201).json({ | ||
message : 'Product deleted successfully', | ||
success : true, | ||
error : false, | ||
data : deleteProduct | ||
}) | ||
|
||
|
||
} catch (error) { | ||
res.status(404).json({ | ||
message : error.message || error, | ||
success : false, | ||
error : true | ||
}) | ||
} | ||
|
||
} | ||
|
||
export default deleteAddToCartProduct; |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import userAddressModel from "../../models/userAddressModel.js"; | ||
|
||
|
||
const displayUserAddress = async (req, res) => { | ||
try { | ||
const currentUserId = req.userID; | ||
|
||
|
||
const userAddress = await userAddressModel.find({userId: currentUserId}); | ||
|
||
res.status(200).json({ | ||
message: "User Address fetched successfully", | ||
success: true, | ||
error: false, | ||
data: userAddress | ||
|
||
}); | ||
console.log('userAddress: ',userAddress) | ||
} catch (error) { | ||
console.log(error); | ||
res.status(400).json({ | ||
message: error.message, | ||
error: true, | ||
success: false | ||
|
||
}); | ||
|
||
} | ||
} | ||
|
||
export default displayUserAddress; |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import userAddressModel from '../../models/userAddressModel.js'; | ||
|
||
const userAddress = async (req, res) => { | ||
|
||
try { | ||
const userShippingAddress = req.body; | ||
|
||
const userId = req.userID; | ||
console.log('userId: ',userId) | ||
const payload = { | ||
...userShippingAddress, | ||
userId: userId, | ||
|
||
}; | ||
const userAddress = new userAddressModel(payload); | ||
const savedUserAddress = await userAddress.save(); | ||
res.status(200).json({ | ||
message: "User Address Saved Successfully", | ||
data: savedUserAddress, | ||
error: false, | ||
success: true | ||
}); | ||
|
||
console.log('userShippingAddress: ',userShippingAddress) | ||
} catch (error) { | ||
console.log(error); | ||
res.status(500).json({message: "Internal Server Error"}); | ||
|
||
} | ||
} | ||
|
||
export default userAddress; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import mongoose from "mongoose"; | ||
|
||
const userAddressSchema = mongoose.Schema({ | ||
userId: String, | ||
fullName: String, | ||
landMark: String, | ||
address: String, | ||
state: String, | ||
postalCode: String, | ||
contactNumber: String, | ||
} ,{ | ||
timestamps: true | ||
}); | ||
|
||
const userAddress = mongoose.model('UserAddress', userAddressSchema); | ||
export default userAddress; |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.