@feardread/fear 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -134,18 +134,23 @@ exports.getProductStats = tryCatch(async (req, res) => {
134
134
  * @param {Object} req - Express request object
135
135
  * @param {Object} res - Express response object
136
136
  */
137
- exports.featured = async (req, res) => {
138
- console.log('Featured Product route called ');
139
- const featuredProducts = Product.find({isFeatured: true})
140
- console.log('Featured Product route called ', featuredProducts);
137
+ exports.featured = tryCatch(async (req, res) => {
138
+ const featuredProducts = await Product.find({isFeatured: true});
139
+ console.log('featured results = ', featuredProducts);
140
+ if (featuredProducts) {
141
+ return res.status(200).json({ success: true, result: featuredProducts })
142
+ }
143
+
144
+
145
+ /*
141
146
  return res.status(200).json({
142
147
  success: true,
143
148
  message: `Top ${featuredProducts.length} trending products`,
144
149
  result: featuredProducts,
145
- count: featuredProducts.length,
146
- sortBy
150
+ count: featuredProducts.length
147
151
  });
148
- };
152
+ */
153
+ });
149
154
 
150
155
  exports.productSearch = tryCatch(async (req, res) => {
151
156
  return await productSearch(req.query, Product)
package/models/product.js CHANGED
@@ -7,12 +7,13 @@ const productSchema = new mongoose.Schema({
7
7
  slug: { type: String, required: false, unique: true, lowercase: true },
8
8
  description: { type: String, required: true },
9
9
  price: { type: Number, required: true },
10
+ discount: { type: Number, required: false, default: 0 },
10
11
  category: { type: mongoose.Schema.Types.String, ref: "Category" },
11
12
  brand: { type: mongoose.Schema.Types.String, ref: "Brand" , required: false },
12
13
  quantity: { type: Number, required: true },
13
14
  sold: { type: Number, default: 0 },
14
15
  reviews: [Review.schema],
15
- isFeatured: {type: Boolean, required: false, default: true}
16
+ isFeatured: {type: Boolean, required: false, default: false},
16
17
  images: [{
17
18
  public_id: String,
18
19
  url: String
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feardread/fear",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/routes/product.js CHANGED
@@ -10,9 +10,9 @@ module.exports = (fear) => {
10
10
  .post("/new", Product.create)
11
11
  .get("/edit/:id", Product.read);
12
12
 
13
- router.route("/search").post(handler.async(Product.search);
14
- router.route("/featured").get(handler.async(Product.featured));
15
- router.route("/one").get(handler.async(Product.read));
13
+ router.route("/search").post(Product.search);
14
+ router.route("/featured").get(Product.featured);
15
+ router.route("/one").get(Product.read);
16
16
  router.route("/:id")
17
17
  .get(Product.read)
18
18
  .put(Product.update)