Skip to content

Instantly share code, notes, and snippets.

View mohrazzak's full-sized avatar

Mohammad Abdalrazzak mohrazzak

View GitHub Profile
@mohrazzak
mohrazzak / gist:d546855b7097a41759f7b8062d755d23
Created August 31, 2022 16:22
Create product controller
exports.createProduct = async (req, res, next) => {
try {
if (!req.file) {
const error = new Error("No image provided.");
error.statusCode = 422;
return next(error);
}
const image = req.file.path.replace("\\", "/").replace("\\", "/");
const { title, price, category, desc } = req.body;
const product = new Product({