Files
Craze-Data-check/api/debug-db.js
T

27 lines
953 B
JavaScript
Raw Normal View History

import { createClient } from '@supabase/supabase-js';
const SUPABASE_URL = process.env.SUPABASE_URL || 'https://hwithddwaapyhnfwcesj.supabase.co';
const SUPABASE_KEY = process.env.SUPABASE_SERVICE_KEY || process.env.SUPABASE_ANON_KEY;
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY);
export default async function handler(req, res) {
try {
const { data: products } = await supabase.from('products').select('*').limit(5);
const { data: history } = await supabase.from('products_history').select('*').limit(5);
const { count } = await supabase.from('products').select('*', { count: 'exact', head: true });
return res.json({
productsCount: count,
sampleProducts: products,
sampleHistory: history,
env: {
hasUrl: !!process.env.SUPABASE_URL,
hasKey: !!process.env.SUPABASE_SERVICE_KEY
}
});
} catch (err) {
return res.status(500).json({ error: err.message });
}
}