diff --git a/backend/src/controllers/themes.ts b/backend/src/controllers/themes.ts index 442eb982..73091dd7 100644 --- a/backend/src/controllers/themes.ts +++ b/backend/src/controllers/themes.ts @@ -10,9 +10,6 @@ interface Translations { }; } -/** - * Laadt de vertalingen uit een YAML-bestand - */ function loadTranslations(language: string): Translations { try { const filePath = path.join(process.cwd(), '_i18n', `${language}.yml`); @@ -20,7 +17,7 @@ function loadTranslations(language: string): Translations { return yaml.load(yamlFile) as Translations; } catch (error) { console.error( - `Kan vertaling niet laden voor ${language}, fallback naar Nederlands` + `Cant load for language: ${language}, fallen back on dutch` ); console.error(error); const fallbackPath = path.join(process.cwd(), '_i18n', 'nl.yml'); @@ -28,9 +25,7 @@ function loadTranslations(language: string): Translations { } } -/** - * GET /themes → Haalt de lijst met thema's op inclusief vertalingen - */ + export function getThemes(req: Request, res: Response) { const language = (req.query.language as string)?.toLowerCase() || 'nl'; const translations = loadTranslations(language); @@ -48,9 +43,7 @@ export function getThemes(req: Request, res: Response) { res.json(themeList); } -/** - * GET /themes/:theme → Geeft de HRUIDs terug voor een specifiek thema - */ + export function getThemeByTitle(req: Request, res: Response) { const themeKey = req.params.theme; const theme = themes.find((t) => { @@ -60,6 +53,6 @@ export function getThemeByTitle(req: Request, res: Response) { if (theme) { res.json(theme.hruids); } else { - res.status(404).json({ error: 'Thema niet gevonden' }); + res.status(404).json({ error: 'Theme not found' }); } } diff --git a/backend/src/routes/themes.ts b/backend/src/routes/themes.ts index 3185640e..434ee687 100644 --- a/backend/src/routes/themes.ts +++ b/backend/src/routes/themes.ts @@ -3,7 +3,12 @@ import { getThemes, getThemeByTitle } from '../controllers/themes.js'; const router = express.Router(); +// query: language +// Route to fetch list of {key, title, description, image} themes in their respective language router.get('/', getThemes); + +// arg: theme (key) +// Route to fetch list of hruids based on theme router.get('/:theme', getThemeByTitle); export default router;