const express = require('express');
const router = express.Router();
const { getStats, getCVEs } = require('../controllers/tv.controller');

// Kein normaler Login (TV-Display im Büro) — aber ein Shared-Key statt komplett offen ins Netz.
function requireTvKey(req, res, next) {
    if (!process.env.TV_DASHBOARD_KEY || req.query.key !== process.env.TV_DASHBOARD_KEY) {
        return res.status(401).json({ status: 'error', message: 'Unauthorized' });
    }
    next();
}

router.get('/stats', requireTvKey, getStats);
router.get('/cves', requireTvKey, getCVEs);

module.exports = router;
