import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import { authorize } from '../middleware/authorizationMiddleware.js';
import clubDocumentController, {
  uploadMiddleware,
} from '../controllers/clubDocumentController.js';

const router = express.Router();

router.use(authenticate);

router.get('/:clubId', authorize('settings', 'read'), clubDocumentController.listClubDocuments);
router.get('/:clubId/:documentId/download', authorize('settings', 'read'), clubDocumentController.downloadClubDocument);
router.post('/:clubId', authorize('settings', 'write'), uploadMiddleware, clubDocumentController.createClubDocument);
router.put('/:clubId/:documentId', authorize('settings', 'write'), uploadMiddleware, clubDocumentController.updateClubDocument);
router.patch('/:clubId/:documentId/archive', authorize('settings', 'write'), clubDocumentController.archiveClubDocument);
router.delete('/:clubId/:documentId', authorize('settings', 'write'), clubDocumentController.deleteClubDocument);

export default router;
