refactor(backend): Preparation for learning content from multiple data sources.
Refactored the service layer so that it becomes possible to add another source for learning objects and learning paths.
This commit is contained in:
parent
8c22b72b22
commit
d7728ddd03
10 changed files with 219 additions and 117 deletions
|
@ -0,0 +1,30 @@
|
|||
import {FilteredLearningObject} from "../../interfaces/learningContent";
|
||||
import dwengoApiLearningObjectProvider from "./dwengo-api/dwengo-api-learning-object-provider";
|
||||
|
||||
/**
|
||||
* Service providing access to data about learning objects from the appropriate data source (database or Dwengo-api)
|
||||
*/
|
||||
const learningObjectService = {
|
||||
/**
|
||||
* Fetches a single learning object by its HRUID
|
||||
*/
|
||||
getLearningObjectById(hruid: string, language: string): Promise<FilteredLearningObject | null> {
|
||||
return dwengoApiLearningObjectProvider.getLearningObjectById(hruid, language);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch full learning object data (metadata)
|
||||
*/
|
||||
getLearningObjectsFromPath(hruid: string, language: string): Promise<FilteredLearningObject[]> {
|
||||
return dwengoApiLearningObjectProvider.getLearningObjectsFromPath(hruid, language);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch only learning object HRUIDs
|
||||
*/
|
||||
getLearningObjectIdsFromPath(hruid: string, language: string): Promise<string[]> {
|
||||
return dwengoApiLearningObjectProvider.getLearningObjectIdsFromPath(hruid, language);
|
||||
}
|
||||
};
|
||||
|
||||
export default learningObjectService;
|
Loading…
Add table
Add a link
Reference in a new issue