import { Router } from 'express';
import auth from '../middlewares/auth.js';
import AbstractProductController from '../controllers/abstractproduct.js';
import existance from '../middlewares/existance.js';
import multer from 'multer';
import path from 'path';

const upload = multer(({
    dest: path.join(path.resolve(path.dirname('')), "/temp")
}));

const AbstractProductRouter = new Router();

AbstractProductRouter.post('/create', upload.single("file"), auth.authenticate, existance.groupExists, auth.userIsInGroup, AbstractProductController.create);
AbstractProductRouter.post('/update', upload.single("file"), auth.authenticate, existance.groupExists, auth.userIsInGroup, existance.abstractProductExists, AbstractProductController.update);

export default AbstractProductRouter;