Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio), valuation and sort-by-price, card detail pricing UI, and nearby store discovery via home zip and OSM geo clients. Co-authored-by: Cursor <cursoragent@cursor.com>
24 lines
763 B
JavaScript
24 lines
763 B
JavaScript
import { getCardPricing } from '../../../../lib/pricing/pricing-service.js';
|
|
|
|
export default async function handler(req, res) {
|
|
if (req.method !== 'GET') {
|
|
return res.status(405).json({ error: 'Method not allowed' });
|
|
}
|
|
|
|
try {
|
|
const cardId = parseInt(req.query.id, 10);
|
|
if (!req.query.id || Number.isNaN(cardId) || cardId <= 0) {
|
|
return res.status(400).json({ error: 'Valid card ID is required' });
|
|
}
|
|
|
|
const pricing = await getCardPricing(cardId);
|
|
if (!pricing) {
|
|
return res.status(404).json({ error: 'Card not found' });
|
|
}
|
|
|
|
return res.status(200).json(pricing);
|
|
} catch (err) {
|
|
console.error('[GET /api/cards/[id]/pricing]', err);
|
|
return res.status(500).json({ error: 'Internal server error' });
|
|
}
|
|
}
|