fix(shops): parse multipart logo upload on PATCH /shops/:id/logo

req.files.logo relied on an express-form-data style parser that was
removed app-wide, so the route never had a multipart parser and every
logo upload failed with "لطفاً لوگوی فروشگاه را انتخاب کنید" even
though the client had already picked and sent an image. Add the same
multer-based pattern already used for profile_image and shop-products
image uploads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
payacom
2026-10-28 16:46:04 +03:30
parent e5dcd0f1b2
commit 6e25e1a38a
2 changed files with 23 additions and 3 deletions

View File

@@ -281,7 +281,7 @@ const updateShopLogo = async (req, res, next) => {
if (error === 'NOT_FOUND') return shopError(res, 404, 'فروشگاه یافت نشد')
if (error === 'FORBIDDEN') return shopError(res, 403, 'شما مالک این فروشگاه نیستید')
const logo = req.files?.logo
const logo = req.file
if (!logo) {
return shopError(res, 422, 'لطفاً لوگوی فروشگاه را انتخاب کنید')
}
@@ -289,7 +289,7 @@ const updateShopLogo = async (req, res, next) => {
const uploadDir = path.join(__dirname, '../../../storage/shops')
fs.ensureDirSync(uploadDir)
const uniqueFileName = `${shop._id}-${Date.now()}${path.extname(logo.name)}`
const uniqueFileName = `${shop._id}-${Date.now()}${path.extname(logo.originalname || '')}`
const filePath = path.join(uploadDir, uniqueFileName)
await fs.move(logo.path, filePath, { overwrite: true })
await optimizeImageFile(filePath, { maxDimension: 800 })