dok/routes/himmelstor-daily.route.js
2026-04-14 08:31:15 +01:00

32 lines
1.1 KiB
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.

/* ============================================================
routes/himmelstor-daily.route.js
GET /api/himmelstor/daily/progress welche Stationen heute erledigt
============================================================ */
const express = require("express");
const router = express.Router();
const db = require("../database/database");
function requireLogin(req, res, next) {
if (!req.session?.user) return res.status(401).json({ error: "Nicht eingeloggt" });
next();
}
/* ── GET /api/himmelstor/daily/progress ────────────────── */
router.get("/progress", requireLogin, async (req, res) => {
const userId = req.session.user.id;
try {
const [rows] = await db.query(
"SELECT event_id FROM daily_completions WHERE user_id = ?",
[userId]
);
const completed = rows.map(r => r.event_id);
res.json({ completed, total: 7, allDone: completed.length >= 7 });
} catch (err) {
console.error("[Daily] Fortschritt laden:", err);
res.status(500).json({ error: "DB Fehler" });
}
});
module.exports = router;