'use strict';

/**
 * GET /api/desk-showcase (Truth-Everywhere Part 2, item 6) — REAL data for the
 * pricing Desk showcase (alt-line ladder + same-team correlation). Public,
 * cache-only. { available:false } when the board has nothing → the visuals hide.
 */
const express = require('express');
const { createRateLimit } = require('../middleware/rateLimit');
const deskShowcaseService = require('../services/deskShowcaseService');

const router = express.Router();
router.use(createRateLimit({ windowMs: 60_000, max: 60 }));

router.get('/', async (req, res) => {
  try {
    const data = await deskShowcaseService.getDeskShowcase({});
    res.set('Cache-Control', 'public, max-age=300');
    return res.json(data);
  } catch (err) {
    console.error('[desk-showcase]', err.message);
    return res.status(200).json({ available: false });
  }
});

module.exports = router;
