style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-03-11 03:09:12 +00:00
parent aa1a85e64e
commit 2a2881ec30
84 changed files with 846 additions and 1013 deletions

View file

@ -1,38 +1,35 @@
import { Request, Response } from 'express';
import { FALLBACK_LANG } from '../config.js';
import {FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier} from '../interfaces/learning-content';
import learningObjectService from "../services/learning-objects/learning-object-service";
import {EnvVars, getEnvVar} from "../util/envvars";
import {Language} from "../entities/content/language";
import {BadRequestException} from "../exceptions";
import attachmentService from "../services/learning-objects/attachment-service";
import {NotFoundError} from "@mikro-orm/core";
import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '../interfaces/learning-content';
import learningObjectService from '../services/learning-objects/learning-object-service';
import { EnvVars, getEnvVar } from '../util/envvars';
import { Language } from '../entities/content/language';
import { BadRequestException } from '../exceptions';
import attachmentService from '../services/learning-objects/attachment-service';
import { NotFoundError } from '@mikro-orm/core';
function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier {
if (!req.params.hruid) {
throw new BadRequestException("HRUID is required.");
throw new BadRequestException('HRUID is required.');
}
return {
hruid: req.params.hruid as string,
language: (req.query.language || getEnvVar(EnvVars.FallbackLanguage)) as Language,
version: parseInt(req.query.version as string)
version: parseInt(req.query.version as string),
};
}
function getLearningPathIdentifierFromRequest(req: Request): LearningPathIdentifier {
if (!req.query.hruid) {
throw new BadRequestException("HRUID is required.");
throw new BadRequestException('HRUID is required.');
}
return {
hruid: req.params.hruid as string,
language: (req.query.language as Language) || FALLBACK_LANG
}
language: (req.query.language as Language) || FALLBACK_LANG,
};
}
export async function getAllLearningObjects(
req: Request,
res: Response
): Promise<void> {
export async function getAllLearningObjects(req: Request, res: Response): Promise<void> {
const learningPathId = getLearningPathIdentifierFromRequest(req);
const full = req.query.full;
@ -46,10 +43,7 @@ export async function getAllLearningObjects(
res.json(learningObjects);
}
export async function getLearningObject(
req: Request,
res: Response
): Promise<void> {
export async function getLearningObject(req: Request, res: Response): Promise<void> {
const learningObjectId = getLearningObjectIdentifierFromRequest(req);
const learningObject = await learningObjectService.getLearningObjectById(learningObjectId);
@ -71,5 +65,5 @@ export async function getAttachment(req: Request, res: Response): Promise<void>
if (!attachment) {
throw new NotFoundError(`Attachment ${name} not found`);
}
res.setHeader("Content-Type", attachment.mimeType).send(attachment.content)
res.setHeader('Content-Type', attachment.mimeType).send(attachment.content);
}