tested and fixed
This commit is contained in:
		@@ -4,6 +4,7 @@ import AbstractProductController from '../controllers/abstractproduct.js';
 | 
			
		||||
import multer from 'multer';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
import tryHandler from '../response/errorHandler.js';
 | 
			
		||||
import existance from '../middlewares/existance.js';
 | 
			
		||||
 | 
			
		||||
const upload = multer(({
 | 
			
		||||
    dest: path.join(path.resolve(path.dirname('')), "/temp")
 | 
			
		||||
@@ -12,6 +13,6 @@ const upload = multer(({
 | 
			
		||||
const AbstractProductRouter = new Router();
 | 
			
		||||
 | 
			
		||||
AbstractProductRouter.post('/create', upload.single("file"), tryHandler(auth.authenticate), tryHandler(auth.userIsInGroup), tryHandler(AbstractProductController.create));
 | 
			
		||||
AbstractProductRouter.post('/update', upload.single("file"), tryHandler(auth.authenticate), tryHandler(auth.userIsInGroup), tryHandler(AbstractProductController.update));
 | 
			
		||||
AbstractProductRouter.post('/update', upload.single("file"), tryHandler(auth.authenticate), tryHandler(auth.userIsInGroup), tryHandler(existance.localIdExists), tryHandler(AbstractProductController.update));
 | 
			
		||||
 | 
			
		||||
export default AbstractProductRouter;
 | 
			
		||||
@@ -2,10 +2,11 @@ import { Router } from 'express';
 | 
			
		||||
import auth from '../middlewares/auth.js';
 | 
			
		||||
import CategoryController from '../controllers/category.js';
 | 
			
		||||
import tryHandler from '../response/errorHandler.js';
 | 
			
		||||
import existance from '../middlewares/existance.js';
 | 
			
		||||
 | 
			
		||||
const CategoryRouter = new Router();
 | 
			
		||||
 | 
			
		||||
CategoryRouter.post('/create', tryHandler(auth.authenticate), tryHandler(CategoryController.create));
 | 
			
		||||
CategoryRouter.post('/update', tryHandler(auth.authenticate), tryHandler(CategoryController.update));
 | 
			
		||||
CategoryRouter.post('/create', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(CategoryController.create));
 | 
			
		||||
CategoryRouter.post('/update', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(existance.localIdExists), tryHandler(CategoryController.update));
 | 
			
		||||
 | 
			
		||||
export default CategoryRouter;
 | 
			
		||||
@@ -2,11 +2,12 @@ import { Router } from 'express';
 | 
			
		||||
import auth from '../middlewares/auth.js';
 | 
			
		||||
import GroupController from '../controllers/group.js';
 | 
			
		||||
import tryHandler from '../response/errorHandler.js';
 | 
			
		||||
import existance from '../middlewares/existance.js';
 | 
			
		||||
 | 
			
		||||
const GroupRouter = new Router();
 | 
			
		||||
 | 
			
		||||
GroupRouter.post('/create/:groupName', tryHandler(auth.authenticate), tryHandler(GroupController.create));
 | 
			
		||||
GroupRouter.post('/join/:groupId', tryHandler(auth.authenticate), tryHandler(auth.requirePassword), tryHandler(auth.checkGroupPassword), tryHandler(GroupController.join));
 | 
			
		||||
GroupRouter.post('/password/:groupId', tryHandler(auth.authenticate), tryHandler(auth.authorizeGroupOwner), tryHandler(auth.requirePassword), tryHandler(GroupController.updatePassword));
 | 
			
		||||
GroupRouter.post('/join/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.requirePassword), tryHandler(auth.checkGroupPassword), tryHandler(GroupController.join));
 | 
			
		||||
GroupRouter.post('/password/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.authorizeGroupOwner), tryHandler(auth.requirePassword), tryHandler(GroupController.updatePassword));
 | 
			
		||||
 | 
			
		||||
export default GroupRouter;
 | 
			
		||||
@@ -2,10 +2,11 @@ import { Router } from 'express';
 | 
			
		||||
import auth from '../middlewares/auth.js';
 | 
			
		||||
import ProductController from '../controllers/product.js'
 | 
			
		||||
import tryHandler from '../response/errorHandler.js';
 | 
			
		||||
import existance from '../middlewares/existance.js';
 | 
			
		||||
 | 
			
		||||
const ProductRouter = new Router();
 | 
			
		||||
 | 
			
		||||
ProductRouter.post('/create', tryHandler(auth.authenticate), tryHandler(auth.userIsInGroup), tryHandler(ProductController.create));
 | 
			
		||||
ProductRouter.post('/update', tryHandler(auth.authenticate), tryHandler(auth.userIsInGroup), tryHandler(ProductController.update));
 | 
			
		||||
ProductRouter.post('/create', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(ProductController.create));
 | 
			
		||||
ProductRouter.post('/update', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(existance.localIdExists), tryHandler(auth.userIsInGroup), tryHandler(ProductController.update));
 | 
			
		||||
 | 
			
		||||
export default ProductRouter;
 | 
			
		||||
		Reference in New Issue
	
	Block a user