/
Krams
/
nodemon2
Обзор
Документация
Войти
/
Krams
/
nodemon2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/controllers/MapNoticeController.js
31 строка
1 KB
Иван Новиков
final
25 май 2026, 17:46
25 май 2026, 17:46
2c76ffd
Код
Авторство
О чём код?
import { getMapNotice, saveMapNotice } from '../services/MapNoticeService.js'; export async function getMapNoticeController(req, res) { try { const notice = await getMapNotice(); res.json(notice || {}); } catch (error) { res.status(500).json({ error: 'Ошибка при получении примечания карты' }); } } export async function saveMapNoticeController(req, res) { const id = typeof req.body?.id === 'string' ? req.body.id.trim() : ''; const eyebrow = typeof req.body?.eyebrow === 'string' ? req.body.eyebrow.trim() : ''; const title = typeof req.body?.title === 'string' ? req.body.title.trim() : ''; const body = typeof req.body?.body === 'string' ? req.body.body.trim() : ''; const theme = typeof req.body?.theme === 'string' ? req.body.theme.trim() : 'warning'; const dh = req.body?.display_hidden; const display_hidden = dh === true || dh === 'true' || dh === 1 || dh === '1'; if (!id) { return res.status(400).json({ error: 'Поле id обязательно' }); } try { const notice = await saveMapNotice({ id, eyebrow, title, body, theme, display_hidden }); res.json(notice); } catch (error) { res.status(500).json({ error: 'Ошибка при сохранении примечания карты' }); } }