Files
harheimertc/server/api/spielplan/seasons.get.js
Torsten Schulz (local) 3586704cce
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 10m29s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped
Update file permissions for multiple server and test files to executable mode
2026-07-15 08:45:12 +02:00

26 lines
749 B
JavaScript
Executable File

import { getCurrentSeasonSlug, listSpielplanSeasons } from '../../utils/spielplan-data.js'
import { error as loggerError } from '../../utils/logger.js'
export default defineEventHandler(async () => {
try {
const seasons = await listSpielplanSeasons()
const currentSeason = getCurrentSeasonSlug()
const defaultSeason = seasons.find((season) => season.slug === currentSeason)?.slug || seasons[0]?.slug || null
return {
success: true,
seasons,
currentSeason,
defaultSeason
}
} catch (error) {
loggerError('Fehler beim Laden der Spielplan-Saisons:', { error })
return {
success: false,
seasons: [],
currentSeason: getCurrentSeasonSlug(),
defaultSeason: null
}
}
})