Compare commits

..

No commits in common. "1c43cdfca09e043507030bbf29c21fabce5f70ec" and "a224bbce985877a03ecf641a1fcd94c2e1045e9e" have entirely different histories.

2 changed files with 0 additions and 66 deletions

View File

@ -779,72 +779,6 @@ app.post("/api/players/:id/assign-team", async (req, res) => {
//Multer Storage fuer Galleriebilder
const galleryStorage = multer.diskStorage({
destination: (req, file, cb) => {
const dir = "./uploads/gallery";
fs.mkdirSync(dir, { recursive: true });
cb(null, dir);
},
filename: (req, file, cb) => {
const ext = path.extname(file.originalname);
const filename = Date.now() + ext;
cb(null, filename);
},
});
const uploadGalleryImage = multer({ storage: galleryStorage });
//Gallery Image Upload
app.post("/api/gallery", uploadGalleryImage.single("image"), async (req, res) => {
const { title } = req.body;
if (!req.file) return res.status(400).send("Kein Bild hochgeladen");
const imageUrl = `/uploads/gallery/${req.file.filename}`;
try {
const result = await pool.query(
"INSERT INTO gallery_images (image_url, title) VALUES ($1, $2) RETURNING *",
[imageUrl, title || null]
);
res.status(201).json(result.rows[0]);
} catch (err) {
console.error("Fehler beim Speichern des Galeriebilds:", err);
res.status(500).send("Fehler beim Speichern");
}
});
//Get all gallery images
app.get("/api/gallery", async (req, res) => {
try {
const result = await pool.query("SELECT * FROM gallery_images ORDER BY uploaded_at DESC");
res.json(result.rows);
} catch (err) {
console.error("Fehler beim Laden der Galerie:", err);
res.status(500).send("Fehler beim Laden");
}
});
//Delete image
app.delete("/api/gallery/:id", async (req, res) => {
const { id } = req.params;
try {
const result = await pool.query("DELETE FROM gallery_images WHERE id = $1 RETURNING *", [id]);
if (result.rowCount === 0) return res.status(404).send("Bild nicht gefunden");
// Optional: Datei auch vom Dateisystem löschen
const filePath = path.join(__dirname, result.rows[0].image_url);
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
res.send("Bild erfolgreich gelöscht");
} catch (err) {
console.error("Fehler beim Löschen des Bildes:", err);
res.status(500).send("Fehler beim Löschen");
}
});
// Server starten // Server starten

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB