Refactor code structure for improved readability and maintainability

This commit is contained in:
Marco Mooren
2026-05-11 02:18:14 +02:00
parent 00246389bc
commit 86690c3753
5 changed files with 1443 additions and 615 deletions

View File

@@ -46,9 +46,9 @@ router.post('/:id/vote', requireUser, (req, res) => {
const id = Number(req.params.id);
if (!getStation(id)) return res.status(404).json({ error: 'not found' });
const raw = req.body?.value;
const value = raw === 1 || raw === '1' || raw === 'up' ? 1
: raw === -1 || raw === '-1' || raw === 'down' ? -1
: raw === 0 || raw === '0' || raw === null || raw === 'clear' ? 0
const value = raw === 1 || raw === '1' || raw === 'up' ? 1
: raw === -1 || raw === '-1' || raw === 'down' ? -1
: raw === 0 || raw === '0' || raw === null || raw === 'clear' ? 0
: NaN;
if (Number.isNaN(value)) return res.status(400).json({ error: 'value must be 1, -1 or 0' });
res.json(castVote(req.user.id, id, value));