style: fix linting issues met Prettier
This commit is contained in:
		
							parent
							
								
									56d34adbc0
								
							
						
					
					
						commit
						7ad808cf3b
					
				
					 34 changed files with 244 additions and 214 deletions
				
			
		|  | @ -9,7 +9,7 @@ import { EnvVars, getNumericEnvVar } from './util/envvars.js'; | |||
| import apiRouter from './routes/router.js'; | ||||
| import swaggerMiddleware from './swagger.js'; | ||||
| import swaggerUi from 'swagger-ui-express'; | ||||
| import {errorHandler} from "./middleware/error-handling/error-handler"; | ||||
| import { errorHandler } from './middleware/error-handling/error-handler'; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import { EnvVars, getEnvVar } from '../util/envvars.js'; | |||
| import { Language } from '../entities/content/language.js'; | ||||
| import attachmentService from '../services/learning-objects/attachment-service.js'; | ||||
| import { NotFoundError } from '@mikro-orm/core'; | ||||
| import {BadRequestException} from "../exceptions/bad-request-exception.js"; | ||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| 
 | ||||
| function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier { | ||||
|     if (!req.params.hruid) { | ||||
|  |  | |||
|  | @ -8,8 +8,8 @@ import { | |||
|     personalizedForGroup, | ||||
|     personalizedForStudent, | ||||
| } from '../services/learning-paths/learning-path-personalization-util.js'; | ||||
| import {BadRequestException} from "../exceptions/bad-request-exception.js"; | ||||
| import {NotFoundException} from "../exceptions/not-found-exception.js"; | ||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| 
 | ||||
| /** | ||||
|  * Fetch learning paths based on query parameters. | ||||
|  |  | |||
|  | @ -60,7 +60,7 @@ export async function createStudentHandler(req: Request, res: Response) { | |||
| 
 | ||||
|     if (!newUser) { | ||||
|         res.status(500).json({ | ||||
|             error: 'Something went wrong while creating student' | ||||
|             error: 'Something went wrong while creating student', | ||||
|         }); | ||||
|         return; | ||||
|     } | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import {EntityRepository, FilterQuery} from '@mikro-orm/core'; | ||||
| import {EntityAlreadyExistsException} from "../exceptions/entity-already-exists-exception"; | ||||
| import { EntityRepository, FilterQuery } from '@mikro-orm/core'; | ||||
| import { EntityAlreadyExistsException } from '../exceptions/entity-already-exists-exception'; | ||||
| 
 | ||||
| export abstract class DwengoEntityRepository<T extends object> extends EntityRepository<T> { | ||||
|     public async save(entity: T, options?: {preventOverwrite?: boolean}): Promise<void> { | ||||
|         if (options?.preventOverwrite && await this.findOne(entity)) { | ||||
|     public async save(entity: T, options?: { preventOverwrite?: boolean }): Promise<void> { | ||||
|         if (options?.preventOverwrite && (await this.findOne(entity))) { | ||||
|             throw new EntityAlreadyExistsException(`A ${this.getEntityName()} with this identifier already exists.`); | ||||
|         } | ||||
|         await this.getEntityManager().persistAndFlush(entity); | ||||
|  |  | |||
|  | @ -27,4 +27,4 @@ export class ClassJoinRequest { | |||
| 
 | ||||
|     @Enum(() => ClassJoinRequestStatus) | ||||
|     status!: ClassJoinRequestStatus; | ||||
| } | ||||
| } | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {ExceptionWithHttpState} from "./exception-with-http-state.js"; | ||||
| import { ExceptionWithHttpState } from './exception-with-http-state.js'; | ||||
| 
 | ||||
| /** | ||||
|  * Exception for HTTP 400 Bad Request | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {ExceptionWithHttpState} from "./exception-with-http-state.js"; | ||||
| import { ExceptionWithHttpState } from './exception-with-http-state.js'; | ||||
| 
 | ||||
| /** | ||||
|  * Exception for HTTP 409 Conflict | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {ConflictException} from "./conflict-exception"; | ||||
| import { ConflictException } from './conflict-exception'; | ||||
| 
 | ||||
| export class EntityAlreadyExistsException extends ConflictException { | ||||
|     constructor(message: string) { | ||||
|  |  | |||
|  | @ -2,8 +2,10 @@ | |||
|  * Exceptions which are associated with a HTTP error code. | ||||
|  */ | ||||
| export abstract class ExceptionWithHttpState extends Error { | ||||
|     constructor(public status: number, public error: string) { | ||||
|     constructor( | ||||
|         public status: number, | ||||
|         public error: string | ||||
|     ) { | ||||
|         super(error); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {ExceptionWithHttpState} from "./exception-with-http-state.js"; | ||||
| import { ExceptionWithHttpState } from './exception-with-http-state.js'; | ||||
| 
 | ||||
| /** | ||||
|  * Exception for HTTP 403 Forbidden | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {ExceptionWithHttpState} from "./exception-with-http-state.js"; | ||||
| import { ExceptionWithHttpState } from './exception-with-http-state.js'; | ||||
| 
 | ||||
| /** | ||||
|  * Exception for HTTP 404 Not Found | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {ExceptionWithHttpState} from "./exception-with-http-state.js"; | ||||
| import { ExceptionWithHttpState } from './exception-with-http-state.js'; | ||||
| 
 | ||||
| /** | ||||
|  * Exception for HTTP 401 Unauthorized | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import {getStudentRepository} from "../data/repositories"; | ||||
| import { getStudentRepository } from '../data/repositories'; | ||||
| 
 | ||||
| export interface StudentDTO { | ||||
|     id: string; | ||||
|  | @ -27,6 +27,6 @@ export function mapToStudent(studentData: StudentDTO): Student { | |||
|     return getStudentRepository().create({ | ||||
|         username: studentData.username, | ||||
|         firstName: studentData.firstName, | ||||
|         lastName: studentData.lastName | ||||
|         lastName: studentData.lastName, | ||||
|     }); | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import {getTeacherRepository} from "../data/repositories"; | ||||
| import { getTeacherRepository } from '../data/repositories'; | ||||
| 
 | ||||
| export interface TeacherDTO { | ||||
|     id: string; | ||||
|  | @ -27,6 +27,6 @@ export function mapToTeacher(teacherData: TeacherDTO): Teacher { | |||
|     return getTeacherRepository().create({ | ||||
|         username: teacherData.username, | ||||
|         firstName: teacherData.firstName, | ||||
|         lastName: teacherData.lastName | ||||
|         lastName: teacherData.lastName, | ||||
|     }); | ||||
| } | ||||
|  |  | |||
|  | @ -6,8 +6,8 @@ import * as express from 'express'; | |||
| import * as jwt from 'jsonwebtoken'; | ||||
| import { AuthenticatedRequest } from './authenticated-request.js'; | ||||
| import { AuthenticationInfo } from './authentication-info.js'; | ||||
| import {UnauthorizedException} from "../../exceptions/unauthorized-exception"; | ||||
| import {ForbiddenException} from "../../exceptions/forbidden-exception"; | ||||
| import { UnauthorizedException } from '../../exceptions/unauthorized-exception'; | ||||
| import { ForbiddenException } from '../../exceptions/forbidden-exception'; | ||||
| 
 | ||||
| const JWKS_CACHE = true; | ||||
| const JWKS_RATE_LIMIT = true; | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import {NextFunction, Request, Response} from "express"; | ||||
| import {getLogger, Logger} from "../../logging/initalize"; | ||||
| import {ExceptionWithHttpState} from "../../exceptions/exception-with-http-state"; | ||||
| import { NextFunction, Request, Response } from 'express'; | ||||
| import { getLogger, Logger } from '../../logging/initalize'; | ||||
| import { ExceptionWithHttpState } from '../../exceptions/exception-with-http-state'; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -66,7 +66,7 @@ function config(testingMode: boolean = false): Options { | |||
|         password: getEnvVar(EnvVars.DbPassword), | ||||
|         entities: entities, | ||||
|         persistOnCreate: false, // Entities should not be implicitly persisted when calling create(...), but only after
 | ||||
|                                 // They were saved explicitly.
 | ||||
|         // They were saved explicitly.
 | ||||
|         // EntitiesTs: entitiesTs,
 | ||||
| 
 | ||||
|         // Logging
 | ||||
|  |  | |||
|  | @ -92,4 +92,3 @@ export async function getLearningObjectsFromPath(hruid: string, language: string | |||
| export async function getLearningObjectIdsFromPath(hruid: string, language: string): Promise<string[]> { | ||||
|     return (await fetchLearningObjects(hruid, false, language)) as string[]; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ export async function createStudent(userData: StudentDTO): Promise<StudentDTO | | |||
|     const studentRepository = getStudentRepository(); | ||||
| 
 | ||||
|     const newStudent = mapToStudent(userData); | ||||
|     await studentRepository.save(newStudent, {preventOverwrite: true}); | ||||
|     await studentRepository.save(newStudent, { preventOverwrite: true }); | ||||
|     return mapToStudentDTO(newStudent); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,9 +1,4 @@ | |||
| import { | ||||
|     getClassRepository, | ||||
|     getLearningObjectRepository, | ||||
|     getQuestionRepository, | ||||
|     getTeacherRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { getClassRepository, getLearningObjectRepository, getQuestionRepository, getTeacherRepository } from '../data/repositories.js'; | ||||
| import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { getClassStudents } from './classes.js'; | ||||
| import { StudentDTO } from '../interfaces/student.js'; | ||||
|  | @ -31,7 +26,7 @@ export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO | | |||
|     const teacherRepository = getTeacherRepository(); | ||||
| 
 | ||||
|     const newTeacher = mapToTeacher(userData); | ||||
|     await teacherRepository.save(newTeacher, {preventOverwrite: true}); | ||||
|     await teacherRepository.save(newTeacher, { preventOverwrite: true }); | ||||
| 
 | ||||
|     return mapToTeacherDTO(newTeacher); | ||||
| } | ||||
|  |  | |||
		Reference in a new issue
	
	 Lint Action
						Lint Action