Skip to content

Express & Mongo Eval#166

Open
bhdoggett wants to merge 28 commits intoprojectshft:masterfrom
bhdoggett:master
Open

Express & Mongo Eval#166
bhdoggett wants to merge 28 commits intoprojectshft:masterfrom
bhdoggett:master

Conversation

@bhdoggett
Copy link
Copy Markdown

No description provided.

@import "tailwindcss";

:root {
--background: #ea6df5;
Copy link
Copy Markdown

@greypants greypants Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be hotpink

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.json({ message: "Internal servor error", error: err.message });
});

mongoose.connect("mongodb://localhost/products");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add connection handle in case it fails

const currentPage = await Product.find(query)
// Sort products if price exists in query
.sort(
price === "high" ? { price: -1 } : price === "low" ? { price: 1 } : {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use a const on top or a different file for high and low

query.name = { $regex: search, $options: "i" };
}

const productsPerPage = 9;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to define this every time the api is called, can be a const as well

Comment on lines +110 to +111
validateProduct,
validatePageFormat,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love interceptors, big fan

Comment on lines +142 to +146
// const pagenatedReviews = await Review.find({
// _id: { $in: product.reviews },
// })
// .skip((page - 1) * reviewsPerPage)
// .limit(reviewsPerPage);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont commit commented code

validateProduct,
async (req, res, next) => {
try {
// const product = req.product;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch out

import React from "react";
import Image from "next/image";

// type ProductPropsType = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants