Files
harheimertc/server/api/spielplan.get.js
Torsten Schulz (local) 0849c625cb
Some checks failed
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m2s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 33s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
Require Package Version Change / check (pull_request) Failing after 10s
Add script for importing match schedule and logging
- Created `import-spielplan.js` to fetch and parse the match schedule from the specified URL, saving the output as JSON.
- Added `run-spielplan-import.sh` to automate the execution of the import script and log output.
- Introduced `spielplan.html` file to store the downloaded HTML content for further processing.
2026-05-19 16:23:28 +02:00

40 lines
1017 B
JavaScript

import { listSpielplanSeasons, readSpielplanData } from '../utils/spielplan-data.js'
export default defineEventHandler(async (event) => {
try {
const query = getQuery(event)
const [spielplan, seasons] = await Promise.all([
readSpielplanData({ season: query.season }),
listSpielplanSeasons()
])
if (!spielplan.data.length || !spielplan.headers.length) {
return {
success: false,
message: 'Spielplan-Datei nicht gefunden oder leer',
data: [],
headers: []
}
}
return {
success: true,
message: 'Spielplan erfolgreich geladen',
data: spielplan.data,
headers: spielplan.headers,
source: spielplan.source,
filePath: spielplan.filePath,
season: spielplan.season,
seasons
}
} catch (error) {
console.error('Fehler beim Laden des Spielplans:', error)
return {
success: false,
message: 'Fehler beim Laden des Spielplans',
data: [],
headers: []
}
}
})