const express = require('express');
const router  = express.Router();
const fc      = require('../controllers/flashcardController');
const { authMiddleware } = require('../middleware/auth');

router.use(authMiddleware);

router.get   ('/decks',                fc.listDecks);
router.post  ('/decks',                fc.createDeck);
router.put   ('/decks/:id',            fc.updateDeck);
router.delete('/decks/:id',            fc.deleteDeck);
router.get   ('/decks/:id/cards',      fc.getCards);
router.post  ('/decks/:id/cards',      fc.addCard);
router.post  ('/decks/:id/cards/bulk', fc.addCardsBulk);
router.get   ('/decks/:id/study',      fc.getStudySession);
router.put   ('/cards/:id',            fc.updateCard);
router.delete('/cards/:id',            fc.deleteCard);
router.post  ('/cards/:id/review',     fc.submitReview);
router.get   ('/stats',                fc.getStats);

module.exports = router;
