feat(backend): Controller en route voor het aanmaken van leerobjecten aangemaakt.

This commit is contained in:
Gerald Schmittinger 2025-05-05 23:38:18 +02:00
parent 86ba4ea11e
commit 78353d6b65
6 changed files with 81 additions and 6 deletions

View file

@ -9,6 +9,7 @@ import {
} from '@dwengo-1/common/interfaces/learning-content';
import {getLearningObjectRepository} from "../../data/repositories";
import {processLearningObjectZip} from "./learning-object-zip-processing-service";
import {BadRequestException} from "../../exceptions/bad-request-exception";
function getProvider(id: LearningObjectIdentifierDTO): LearningObjectProvider {
if (id.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) {
@ -58,7 +59,7 @@ const learningObjectService = {
const learningObject = await processLearningObjectZip(learningObjectPath);
if (!learningObject.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) {
throw Error("Learning object name must start with the user content prefix!");
throw new BadRequestException("Learning object name must start with the user content prefix!");
}
await learningObjectRepository.save(learningObject, {preventOverwrite: true});