add db api

This commit is contained in:
Max
2025-06-04 18:49:25 +03:00
parent c251a640b6
commit ea691536ac
13 changed files with 376 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
const router = require('express').Router();
const { getSupabaseClient } = require('./supabaseClient');
// Получить все платежи по конкретной квартире с данными сервиса
router.get('/utility-payments', async (req, res) => {
const supabase = getSupabaseClient();
const { apartment_id } = req.query;
if (!apartment_id) return res.status(400).json({ error: 'apartment_id required' });
const { data, error } = await supabase
.from('utility_payments')
.select('*, payment_services(*)')
.eq('apartment_id', apartment_id);
if (error) return res.status(400).json({ error: error.message });
res.json(data);
});
module.exports = router;