From 3e1995e0cf736222c239a2b04f2dddea671fa992 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Fri, 25 Apr 2025 17:48:30 +0200 Subject: [PATCH] Team loeschen --- index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/index.js b/index.js index bda39f3..d2447ff 100644 --- a/index.js +++ b/index.js @@ -330,6 +330,26 @@ app.post("/api/teams", async (req, res) => { } }); +//Team löschen + +app.delete("/api/teams/:id", async (req, res) => { + const { id } = req.params; + + try { + const result = await pool.query("DELETE FROM teams WHERE id = $1", [id]); + + if (result.rowCount === 0) { + return res.status(404).send("Team nicht gefunden"); + } + + res.send("Team gelöscht"); + } catch (err) { + console.error("Fehler beim Löschen:", err); + res.status(500).send("Fehler beim Löschen"); + } +}); + + // Server starten app.listen(port, () => { const nets = os.networkInterfaces();