feat(validation): replace fieldValidation with express-validator on products and tags

Add products.validators.js and tags.validators.js following the same
pattern as articles/users. Wire createProductRules, updateProductRules,
and createTagRules into their respective routes via the validate middleware.
Remove the local fieldValidation helper from both controllers and fix
missing return statements on next() calls in products.controller.js.
This commit is contained in:
2026-04-27 00:04:50 +02:00
parent 80cd96e006
commit 6641da9a3d
6 changed files with 47 additions and 22 deletions
+3 -1
View File
@@ -1,10 +1,12 @@
const express = require('express');
const { createTag, deleteTag, getAllTags } = require('../../../controllers/tags.controller');
const auth = require('../../../middlewares/auth');
const validate = require('../../../middlewares/validate');
const { createTagRules } = require('../../../middlewares/validators/tags.validators');
const tagRouter = express.Router();
tagRouter.post('/', auth.required, createTag);
tagRouter.post('/', auth.required, createTagRules, validate, createTag);
tagRouter.get('/', auth.optional, getAllTags);
tagRouter.delete('/:name', auth.required, deleteTag);