fix: schoonheids fouten review
This commit is contained in:
parent
2b509774b8
commit
317909b67d
4 changed files with 8 additions and 9 deletions
|
@ -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<Translations>(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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export const API_BASE = "http://localhost:3000/api";
|
|
@ -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<T>(path: string, queryParams?: Record<string, any>): Promise<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue