fix: lint
This commit is contained in:
		
							parent
							
								
									6bb8c364b9
								
							
						
					
					
						commit
						5da0720a08
					
				
					 3 changed files with 40 additions and 39 deletions
				
			
		|  | @ -3,6 +3,7 @@ import { themes } from '../data/themes.js'; | |||
| import {DWENGO_API_BASE, FALLBACK_LANG} from '../config.js'; | ||||
| import { fetchWithLogging } from "../util/apiHelper.js"; | ||||
| import { fetchLearningPaths } from "../services/learningPaths.js"; | ||||
| import {LearningPath} from "../interfaces/learningPath"; | ||||
| 
 | ||||
| /** | ||||
|  * Fetch learning paths based on HRUIDs or return all if no HRUIDs are provided. | ||||
|  | @ -14,13 +15,13 @@ export async function getLearningPaths(req: Request, res: Response): Promise<voi | |||
|         const hruids = req.query.hruids; // Can be string or array
 | ||||
|         const language = (req.query.language as string) || FALLBACK_LANG; | ||||
| 
 | ||||
|         let hruidList: string[] = []; | ||||
|         let hruidList: string[]; | ||||
| 
 | ||||
|         if (hruids) { | ||||
|             hruidList = Array.isArray(hruids) ? hruids.map(String) : [String(hruids)]; | ||||
|         } else { | ||||
|             // If no hruids are provided, fetch ALL learning paths
 | ||||
|             hruidList = themes.flatMap((theme) => theme.hruids); | ||||
|             hruidList = themes.flatMap((theme) => {return theme.hruids}); | ||||
|         } | ||||
| 
 | ||||
|         const learningPaths = await fetchLearningPaths(hruidList, language, `HRUIDs: ${hruidList.join(', ')}`); | ||||
|  | @ -41,7 +42,7 @@ export async function getLearningPathsByTheme(req: Request, res: Response): Prom | |||
|         const themeKey = req.params.theme; | ||||
|         const language = (req.query.language as string) || FALLBACK_LANG; | ||||
| 
 | ||||
|         const theme = themes.find((t) => t.title === themeKey); | ||||
|         const theme = themes.find((t) => {return t.title === themeKey}); | ||||
|         if (!theme) { | ||||
|             console.error(`⚠️ WARNING: Theme "${themeKey}" not found.`); | ||||
|             res.status(404).json({ error: 'Theme not found' }); | ||||
|  | @ -75,7 +76,7 @@ export async function searchLearningPaths(req: Request, res: Response): Promise< | |||
|         const apiUrl = `${DWENGO_API_BASE}/learningPath/search`; | ||||
|         const params = { all: query, language }; | ||||
| 
 | ||||
|         const searchResults = await fetchWithLogging<any>(apiUrl, `Search learning paths with query "${query}"`, params); | ||||
|         const searchResults = await fetchWithLogging<LearningPath[]>(apiUrl, `Search learning paths with query "${query}"`, params); | ||||
|         res.json(searchResults ?? []); | ||||
|     } catch (error) { | ||||
|         console.error('❌ Unexpected error searching learning paths:', error); | ||||
|  |  | |||
|  | @ -1,8 +1,23 @@ | |||
| export interface LearningPathResponse { | ||||
|     success: boolean; | ||||
|     source: string; | ||||
|     data: LearningPath[] | null; | ||||
|     message?: string; | ||||
| export interface Transition { | ||||
|     default: boolean; | ||||
|     _id: string; | ||||
|     next: { | ||||
|         _id: string; | ||||
|         hruid: string; | ||||
|         version: number; | ||||
|         language: string; | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| export interface LearningObjectNode { | ||||
|     _id: string; | ||||
|     learningobject_hruid: string; | ||||
|     version: number; | ||||
|     language: string; | ||||
|     start_node?: boolean; | ||||
|     transitions: Transition[]; | ||||
|     created_at: string; | ||||
|     updatedAt: string; | ||||
| } | ||||
| 
 | ||||
| export interface LearningPath { | ||||
|  | @ -22,26 +37,14 @@ export interface LearningPath { | |||
|     __order: number; | ||||
| } | ||||
| 
 | ||||
| export interface LearningObjectNode { | ||||
|     _id: string; | ||||
|     learningobject_hruid: string; | ||||
|     version: number; | ||||
|     language: string; | ||||
|     start_node?: boolean; | ||||
|     transitions: Transition[]; | ||||
|     created_at: string; | ||||
|     updatedAt: string; | ||||
| export interface EducationalGoal { | ||||
|     source: string; | ||||
|     id: string; | ||||
| } | ||||
| 
 | ||||
| export interface Transition { | ||||
|     default: boolean; | ||||
|     _id: string; | ||||
|     next: { | ||||
|         _id: string; | ||||
|         hruid: string; | ||||
|         version: number; | ||||
|         language: string; | ||||
|     }; | ||||
| export interface ReturnValue { | ||||
|     callback_url: string; | ||||
|     callback_schema: Record<string, any>; | ||||
| } | ||||
| 
 | ||||
| export interface LearningObjectMetadata { | ||||
|  | @ -65,16 +68,6 @@ export interface LearningObjectMetadata { | |||
|     return_value?: ReturnValue; | ||||
| } | ||||
| 
 | ||||
| export interface EducationalGoal { | ||||
|     source: string; | ||||
|     id: string; | ||||
| } | ||||
| 
 | ||||
| export interface ReturnValue { | ||||
|     callback_url: string; | ||||
|     callback_schema: Record<string, any>; | ||||
| } | ||||
| 
 | ||||
| export interface FilteredLearningObject { | ||||
|     key: string; | ||||
|     _id: string; | ||||
|  | @ -96,3 +89,10 @@ export interface FilteredLearningObject { | |||
|     skosConcepts?: string[]; | ||||
|     returnValue?: ReturnValue; | ||||
| } | ||||
| 
 | ||||
| export interface LearningPathResponse { | ||||
|     success: boolean; | ||||
|     source: string; | ||||
|     data: LearningPath[] | null; | ||||
|     message?: string; | ||||
| } | ||||
|  |  | |||
|  | @ -50,12 +50,12 @@ export async function getLearningObjectsFromPath( | |||
|                     `Metadata for Learning Object HRUID "${node.learningobject_hruid}" (version ${node.version}, language ${language})` | ||||
|                 ); | ||||
| 
 | ||||
|                 if (!metadata) return null; | ||||
|                 if (!metadata) {return null;} | ||||
| 
 | ||||
|                 const htmlUrl = `${DWENGO_API_BASE}/learningObject/getRaw?hruid=${node.learningobject_hruid}&version=${node.version}&language=${language}`; | ||||
|                 return filterLearningObjectMetadata(metadata, htmlUrl); | ||||
|             }) | ||||
|         ).then((objects) => objects.filter((obj): obj is FilteredLearningObject => obj !== null)); | ||||
|         ).then((objects) => {return objects.filter((obj): obj is FilteredLearningObject => {return obj !== null})}); | ||||
|     } catch (error) { | ||||
|         console.error('Error fetching learning objects:', error); | ||||
|         return []; | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl