style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-05-13 23:45:23 +00:00
parent a65e95ac46
commit 1203f12ff4
33 changed files with 359 additions and 307 deletions

View file

@ -7,8 +7,8 @@ import { BadRequestException } from '../exceptions/bad-request-exception.js';
import { NotFoundException } from '../exceptions/not-found-exception.js';
import { envVars, getEnvVar } from '../util/envVars.js';
import { FilteredLearningObject, LearningObjectIdentifierDTO, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content';
import {UploadedFile} from "express-fileupload";
import {AuthenticatedRequest} from "../middleware/auth/authenticated-request";
import { UploadedFile } from 'express-fileupload';
import { AuthenticatedRequest } from '../middleware/auth/authenticated-request';
function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifierDTO {
if (!req.params.hruid) {
@ -32,12 +32,13 @@ function getLearningPathIdentifierFromRequest(req: Request): LearningPathIdentif
}
export async function getAllLearningObjects(req: Request, res: Response): Promise<void> {
if (req.query.admin) { // If the admin query parameter is present, the user wants to have all learning objects with this admin.
const learningObjects =
await learningObjectService.getLearningObjectsAdministratedBy(req.query.admin as string);
if (req.query.admin) {
// If the admin query parameter is present, the user wants to have all learning objects with this admin.
const learningObjects = await learningObjectService.getLearningObjectsAdministratedBy(req.query.admin as string);
res.json(learningObjects);
} else { // Else he/she wants all learning objects on the path specified by the request parameters.
} else {
// Else he/she wants all learning objects on the path specified by the request parameters.
const learningPathId = getLearningPathIdentifierFromRequest(req);
const full = req.query.full;
@ -86,10 +87,9 @@ export async function handlePostLearningObject(req: AuthenticatedRequest, res: R
if (!req.files || !req.files.learningObject) {
throw new BadRequestException('No file uploaded');
}
const learningObject = await learningObjectService.storeLearningObject(
(req.files.learningObject as UploadedFile).tempFilePath,
[req.auth!.username]
);
const learningObject = await learningObjectService.storeLearningObject((req.files.learningObject as UploadedFile).tempFilePath, [
req.auth!.username,
]);
res.json(learningObject);
}
@ -97,17 +97,17 @@ export async function handleDeleteLearningObject(req: AuthenticatedRequest, res:
const learningObjectId = getLearningObjectIdentifierFromRequest(req);
if (!learningObjectId.version) {
throw new BadRequestException("When deleting a learning object, a version must be specified.");
throw new BadRequestException('When deleting a learning object, a version must be specified.');
}
const deletedLearningObject = await learningObjectService.deleteLearningObject({
hruid: learningObjectId.hruid,
version: learningObjectId.version,
language: learningObjectId.language
language: learningObjectId.language,
});
if (deletedLearningObject) {
res.json(deletedLearningObject);
} else {
throw new NotFoundException("Learning object not found");
throw new NotFoundException('Learning object not found');
}
}

View file

@ -60,7 +60,12 @@ export async function getLearningPaths(req: Request, res: Response): Promise<voi
hruidList = themes.flatMap((theme) => theme.hruids);
}
const learningPaths = await learningPathService.fetchLearningPaths(hruidList, language as Language, `HRUIDs: ${hruidList.join(', ')}`, forGroup);
const learningPaths = await learningPathService.fetchLearningPaths(
hruidList,
language as Language,
`HRUIDs: ${hruidList.join(', ')}`,
forGroup
);
res.json(learningPaths.data);
}
}
@ -71,12 +76,12 @@ function postOrPutLearningPath(isPut: boolean): (req: AuthenticatedRequest, res:
const teacher = await getTeacher(req.auth!.username);
if (isPut) {
if (req.params.hruid !== path.hruid || req.params.language !== path.language) {
throw new BadRequestException("id_not_matching_query_params");
throw new BadRequestException('id_not_matching_query_params');
}
await learningPathService.deleteLearningPath({hruid: path.hruid, language: path.language as Language});
await learningPathService.deleteLearningPath({ hruid: path.hruid, language: path.language as Language });
}
res.json(await learningPathService.createNewLearningPath(path, [teacher]));
}
};
}
export const postLearningPath = postOrPutLearningPath(false);
@ -85,12 +90,12 @@ export const putLearningPath = postOrPutLearningPath(true);
export async function deleteLearningPath(req: AuthenticatedRequest, res: Response): Promise<void> {
const id: LearningPathIdentifier = {
hruid: req.params.hruid,
language: req.params.language as Language
language: req.params.language as Language,
};
const deletedPath = await learningPathService.deleteLearningPath(id);
if (deletedPath) {
res.json(deletedPath);
} else {
throw new NotFoundException("The learning path could not be found.");
throw new NotFoundException('The learning path could not be found.');
}
}