Add 'Vereinsmeisterschaften' link to Navigation component; update CSV header format and add new entry for 2025

This commit is contained in:
Torsten Schulz (local)
2025-10-23 16:52:08 +02:00
parent a4269e970b
commit c6ce26773a
4 changed files with 714 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
import fs from 'fs/promises'
import path from 'path'
export default defineEventHandler(async (event) => {
try {
const { filename, content } = await readBody(event)
if (!filename || !content) {
throw createError({
statusCode: 400,
statusMessage: 'Filename und Content sind erforderlich'
})
}
// Sicherheitsprüfung: Nur bestimmte Dateien erlauben
const allowedFiles = [
'vereinsmeisterschaften.csv',
'mannschaften.csv',
'termine.csv'
]
if (!allowedFiles.includes(filename)) {
throw createError({
statusCode: 403,
statusMessage: 'Datei nicht erlaubt'
})
}
// Pfad zur Datenverzeichnis
const dataDir = path.join(process.cwd(), 'public', 'data')
const filePath = path.join(dataDir, filename)
// Sicherstellen, dass das Verzeichnis existiert
await fs.mkdir(dataDir, { recursive: true })
// Datei schreiben
await fs.writeFile(filePath, content, 'utf8')
return {
success: true,
message: 'Datei erfolgreich gespeichert'
}
} catch (error) {
console.error('Fehler beim Speichern der CSV-Datei:', error)
throw createError({
statusCode: 500,
statusMessage: 'Fehler beim Speichern der Datei'
})
}
})