deckhearth/pages/api/cards/[id]/collections.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

import { sql } from '@vercel/postgres';
export default async function handler(req, res) {
const { id } = req.query;
if (req.method === 'GET') {
try {
// For now, return mock data until we implement the collections table
const mockCardCollections = [
{ id: 1, name: 'My MTG Collection' },
{ id: 4, name: 'Rare Cards' }
];
res.status(200).json(mockCardCollections);
} catch (error) {
console.error('Error fetching card collections:', error);
res.status(500).json({ error: 'Failed to fetch card collections' });
}
} else if (req.method === 'POST') {
try {
const { collectionId } = req.body;
// For now, just return success until we implement the collections table
res.status(200).json({
success: true,
message: 'Card added to collection'
});
} catch (error) {
console.error('Error adding card to collection:', error);
res.status(500).json({ error: 'Failed to add card to collection' });
}
} else {
res.status(405).json({ error: 'Method not allowed' });
}
}