const express = require('express');
const router = express.Router();
const galleryController = require('../controllers/galleryController');
const { protect, adminOnly } = require('../middleware/authMiddleware');

// Public routes
router.get('/galleries', galleryController.getAllGalleries);
router.get('/galleries/slug/:slug', galleryController.getGalleryBySlug);

// Admin routes
router.get('/galleries/:id', protect, adminOnly, galleryController.getGalleryById);
router.post('/galleries', protect, adminOnly, galleryController.createGallery);
router.put('/galleries/:id', protect, adminOnly, galleryController.updateGallery);
router.delete('/galleries/:id', protect, adminOnly, galleryController.deleteGallery);

// Photo management
router.post('/galleries/:id/photos', protect, adminOnly, galleryController.addPhoto);
router.delete('/galleries/:id/photos/:photoId', protect, adminOnly, galleryController.deletePhoto);

module.exports = router;
