import { Router } from 'express';
import { requireAuth } from '../middleware.js';
import { getCatalogState } from '../catalog.js';

const router = Router();

router.get('/', requireAuth, async (req, res) => {
  try {
    const state = await getCatalogState(req.session.userId);
    res.json(state);
  } catch (err) {
    console.error(err);
    res.status(500).json({ error: 'Failed to load catalog' });
  }
});

export default router;
