Files
multy-stub/server/routers/kfu-m-24-1/sber_mobile/supportApi.js
Дмитриев Максим Сергеевич 5c14212429 fix router
2025-06-11 19:03:58 +03:00

16 lines
743 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const router = require('express').Router();
const { getSupabaseClient } = require('./supabaseClient');
// POST /api/support
router.post('/support', async (req, res) => {
const supabase = getSupabaseClient();
const { user_id, message } = req.body;
if (!user_id || !message) return res.status(400).json({ error: 'user_id и message обязательны' });
const { error } = await supabase
.from('support')
.insert({ user_id, message, is_from_user: true });
if (error) return res.status(400).json({ error: error.message });
res.json({ reply: 'Спасибо за ваше сообщение! Служба поддержки свяжется с вами в ближайшее время.' });
});
module.exports = router;