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,14 @@
const router = require('express').Router();
const { getSupabaseClient } = require('./supabaseClient');
// Получить все сообщения в чате
router.get('/messages', async (req, res) => {
const supabase = getSupabaseClient();
const { chat_id } = req.query;
if (!chat_id) return res.status(400).json({ error: 'chat_id required' });
const { data, error } = await supabase.from('messages').select('*').eq('chat_id', chat_id);
if (error) return res.status(400).json({ error: error.message });
res.json(data);
});
module.exports = router;