const router = require('express').Router();
const { supabaseRouter } = require('./supabaseClient');


// GET /avatar
router.get('/avatar', async (req, res) => {
    const supabase = getSupabaseClient();
    const { user_id } = req.query;
    if (!user_id) return res.status(400).json({ error: 'user_id required' });
    const { data, error } = await supabase.storage.from('avatars').download(`avatar_${user_id}.png`);
    if (error) return res.status(400).json({ error: error.message });
    res.blob(data);
  });

module.exports = router; 