handle all not found errors
This commit is contained in:
@@ -168,6 +168,9 @@ module.exports.createProduct = [
|
||||
.quality(thumbQuality)
|
||||
.write(`./static/uploads/images/products/${thumb}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
if (req.files.more_section_image1) {
|
||||
await jimp.read(req.files.more_section_image1.data)
|
||||
@@ -178,6 +181,9 @@ module.exports.createProduct = [
|
||||
.quality(moreSectionQuality)
|
||||
.write(`./static/uploads/images/products/${more_section_image1}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
if (req.files.more_section_image2) {
|
||||
await jimp.read(req.files.more_section_image2.data)
|
||||
@@ -188,6 +194,9 @@ module.exports.createProduct = [
|
||||
.quality(moreSectionQuality)
|
||||
.write(`./static/uploads/images/products/${more_section_image2}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
if (req.files.render_image1) {
|
||||
await jimp.read(req.files.render_image1.data)
|
||||
@@ -198,6 +207,9 @@ module.exports.createProduct = [
|
||||
.quality(renderImageQuality)
|
||||
.write(`./static/uploads/images/products/${render_image1}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
if (req.files.render_image2) {
|
||||
await jimp.read(req.files.render_image2.data)
|
||||
@@ -208,6 +220,9 @@ module.exports.createProduct = [
|
||||
.quality(renderImageQuality)
|
||||
.write(`./static/uploads/images/products/${render_image2}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
if (req.files.chart_image) {
|
||||
await jimp.read(req.files.chart_image.data)
|
||||
@@ -216,6 +231,9 @@ module.exports.createProduct = [
|
||||
.quality(chartImageQuality)
|
||||
.write(`./static/uploads/images/products/${chart_image}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,8 +267,8 @@ module.exports.getAllProducts = [
|
||||
]
|
||||
|
||||
module.exports.getOneProduct = [
|
||||
async (req, res) => {
|
||||
await Product.findById(req.params.id, async (err, product) => {
|
||||
(req, res) => {
|
||||
Product.findById(req.params.id, (err, product) => {
|
||||
if (err) return res.status(404).json({message: err})
|
||||
return res.json(product)
|
||||
})
|
||||
@@ -394,6 +412,9 @@ module.exports.updateProduct = [
|
||||
.quality(thumbQuality)
|
||||
.write(`./static/uploads/images/products/${thumb}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
if (req.files.more_section_image1) {
|
||||
@@ -406,6 +427,9 @@ module.exports.updateProduct = [
|
||||
.quality(moreSectionQuality)
|
||||
.write(`./static/uploads/images/products/${more_section_image1}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
if (req.files.more_section_image2) {
|
||||
@@ -418,6 +442,9 @@ module.exports.updateProduct = [
|
||||
.quality(moreSectionQuality)
|
||||
.write(`./static/uploads/images/products/${more_section_image2}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
if (req.files.render_image1) {
|
||||
@@ -430,6 +457,9 @@ module.exports.updateProduct = [
|
||||
.quality(renderImageQuality)
|
||||
.write(`./static/uploads/images/products/${render_image1}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
if (req.files.render_image2) {
|
||||
@@ -442,6 +472,9 @@ module.exports.updateProduct = [
|
||||
.quality(renderImageQuality)
|
||||
.write(`./static/uploads/images/products/${render_image2}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
if (req.files.chart_image) {
|
||||
@@ -452,6 +485,9 @@ module.exports.updateProduct = [
|
||||
.quality(chartImageQuality)
|
||||
.write(`./static/uploads/images/products/${chart_image}`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +620,9 @@ module.exports.createProductImage = [
|
||||
return res.json(product)
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
} else {
|
||||
return res.status(422).json({validation: {images: {image: {msg: v_m['fa'].required.image}}}})
|
||||
|
||||
Reference in New Issue
Block a user