const express = require('express');
const router = express.Router();
const ctrl = require('../controllers/redBookController');
const { requireAuth, optionalAuth } = require('../middleware/auth');

// Public (or optional auth for collection status)
router.get('/groups',             ctrl.getGroups);
router.get('/habitats',           ctrl.getHabitats);
router.get('/stats',              optionalAuth, ctrl.getStats);
router.get('/map-data',           ctrl.getMapData);
router.get('/food-web',           ctrl.getFoodWeb);
router.get('/daily',              optionalAuth, ctrl.getDaily);
router.get('/species',            optionalAuth, ctrl.getSpecies);
router.get('/species/:id',        optionalAuth, ctrl.getSpeciesById);
router.get('/biome/:habitatId',   ctrl.getBiomeSpecies);

// Auth required
router.post('/species/:id/collect', requireAuth, ctrl.collectSpecies);
router.get('/collection',           requireAuth, ctrl.getCollection);
router.get('/quests',               optionalAuth, ctrl.getQuests);
router.post('/quests/:id/start',    requireAuth, ctrl.startQuest);
router.get('/sightings',            optionalAuth, ctrl.getSightings);
router.post('/sightings',           requireAuth, ctrl.addSighting);

module.exports = router;
