var express = require('express');
var router = express.Router();

const ads= require("../controllers/adController")
const users= require("../controllers/userController")


//multer
const multer = require('../middleware/multer-config')


/* GET home page. */
router.get('/',users.check, ads.findAll);


router.get('/ads/create',users.checkAuthenticated ,ads.goToCreate);
router.post('/ads/create',multer,users.checkAuthenticated, ads.create);

router.get('/ads/update/:id',users.checkAuthenticated,ads.findOneUpdate);
router.post('/ads/update/:id',multer,users.checkAuthenticated, ads.update)

// Retrieve a single Ad with id
router.get("/show/:slug/:id",users.check, ads.findOne);

// Delete an ad with id
router.get("/ads/:id",users.checkAuthenticated, ads.delete);

router.post('/ad/user/:idad/:idquestion',users.checkAuthenticated, users.reponse);

//comment
// Delete an ad with id
router.post("/ads/ad/comment/:id", ads.question);

module.exports = router;

