mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 14:25:23 +02:00
27 lines
953 B
JavaScript
27 lines
953 B
JavaScript
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 });
|
||
|
|
}
|
||
|
|
}
|