From 317909b67d37d1b0ddd33e9cedb15805bc3922ed Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Sat, 22 Mar 2025 21:15:23 +0100 Subject: [PATCH] fix: schoonheids fouten review --- backend/src/controllers/themes.ts | 6 +++--- backend/src/routes/themes.ts | 6 +++--- frontend/config.ts | 1 - frontend/src/controllers/base-controller.ts | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 frontend/config.ts diff --git a/backend/src/controllers/themes.ts b/backend/src/controllers/themes.ts index 4cfbaa60..8406cf5f 100644 --- a/backend/src/controllers/themes.ts +++ b/backend/src/controllers/themes.ts @@ -8,7 +8,7 @@ interface Translations { }; } -export function getThemes(req: Request, res: Response) { +export function getThemesHandler(req: Request, res: Response) { const language = (req.query.language as string)?.toLowerCase() || 'nl'; const translations = loadTranslations(language); const themeList = themes.map((theme) => ({ @@ -21,10 +21,10 @@ export function getThemes(req: Request, res: Response) { res.json(themeList); } -export function getThemeByTitle(req: Request, res: Response) { +export function getHruidsByThemeHandler(req: Request, res: Response) { const themeKey = req.params.theme; - if (!theme) { + if (!themeKey) { res.status(400).json({ error: 'Missing required field: theme' }); return; } diff --git a/backend/src/routes/themes.ts b/backend/src/routes/themes.ts index 388b3e38..b135d44f 100644 --- a/backend/src/routes/themes.ts +++ b/backend/src/routes/themes.ts @@ -1,14 +1,14 @@ import express from 'express'; -import { getThemes, getThemeByTitle } from '../controllers/themes.js'; +import { getThemesHandler, getHruidsByThemeHandler } 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); +router.get('/', getThemesHandler); // Arg: theme (key) // Route to fetch list of hruids based on theme -router.get('/:theme', getThemeByTitle); +router.get('/:theme', getHruidsByThemeHandler); export default router; diff --git a/frontend/config.ts b/frontend/config.ts deleted file mode 100644 index 656687fd..00000000 --- a/frontend/config.ts +++ /dev/null @@ -1 +0,0 @@ -export const API_BASE = "http://localhost:3000/api"; diff --git a/frontend/src/controllers/base-controller.ts b/frontend/src/controllers/base-controller.ts index e422b4be..adc0c8c0 100644 --- a/frontend/src/controllers/base-controller.ts +++ b/frontend/src/controllers/base-controller.ts @@ -1,10 +1,10 @@ -import { API_BASE } from "../../config.ts"; +import {apiConfig} from "@/config.ts"; export class BaseController { protected baseUrl: string; constructor(basePath: string) { - this.baseUrl = `${API_BASE}/${basePath}`; + this.baseUrl = `${apiConfig.baseUrl}/${basePath}`; } protected async get(path: string, queryParams?: Record): Promise {