style: fix linting issues met Prettier
This commit is contained in:
		
							parent
							
								
									8e2643f596
								
							
						
					
					
						commit
						d88add8351
					
				
					 9 changed files with 48 additions and 52 deletions
				
			
		|  | @ -1,13 +1,7 @@ | |||
| import {Request, Response} from 'express'; | ||||
| import {requireFields} from './error-helper'; | ||||
| import { | ||||
|     createInvitation, | ||||
|     deleteInvitation, | ||||
|     getAllInvitations, | ||||
|     getInvitation, | ||||
|     updateInvitation | ||||
| } from '../services/teacher-invitations'; | ||||
| import {TeacherInvitationData} from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { Request, Response } from 'express'; | ||||
| import { requireFields } from './error-helper'; | ||||
| import { createInvitation, deleteInvitation, getAllInvitations, getInvitation, updateInvitation } from '../services/teacher-invitations'; | ||||
| import { TeacherInvitationData } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| 
 | ||||
| export async function getAllInvitationsHandler(req: Request, res: Response): Promise<void> { | ||||
|     const username = req.params.username; | ||||
|  | @ -62,7 +56,9 @@ export async function deleteInvitationHandler(req: Request, res: Response): Prom | |||
|     requireFields({ sender, receiver, classId }); | ||||
| 
 | ||||
|     const data: TeacherInvitationData = { | ||||
|         sender, receiver, class: classId | ||||
|         sender, | ||||
|         receiver, | ||||
|         class: classId, | ||||
|     }; | ||||
|     const invitation = await deleteInvitation(data); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import {DwengoEntityRepository} from '../dwengo-entity-repository.js'; | ||||
| import {Class} from '../../entities/classes/class.entity.js'; | ||||
| import {TeacherInvitation} from '../../entities/classes/teacher-invitation.entity.js'; | ||||
| import {Teacher} from '../../entities/users/teacher.entity.js'; | ||||
| import {ClassStatus} from "@dwengo-1/common/util/class-join-request"; | ||||
| import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | ||||
| import { Class } from '../../entities/classes/class.entity.js'; | ||||
| import { TeacherInvitation } from '../../entities/classes/teacher-invitation.entity.js'; | ||||
| import { Teacher } from '../../entities/users/teacher.entity.js'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export class TeacherInvitationRepository extends DwengoEntityRepository<TeacherInvitation> { | ||||
|     public async findAllInvitationsForClass(clazz: Class): Promise<TeacherInvitation[]> { | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import {Entity, Enum, ManyToOne} from '@mikro-orm/core'; | ||||
| import { Entity, Enum, ManyToOne } from '@mikro-orm/core'; | ||||
| import { Teacher } from '../users/teacher.entity.js'; | ||||
| import { Class } from './class.entity.js'; | ||||
| import { TeacherInvitationRepository } from '../../data/classes/teacher-invitation-repository.js'; | ||||
| import {ClassStatus} from "@dwengo-1/common/util/class-join-request"; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| /** | ||||
|  * Invitation of a teacher into a class (in order to teach it). | ||||
|  |  | |||
|  | @ -1,17 +1,17 @@ | |||
| import {TeacherInvitation} from '../entities/classes/teacher-invitation.entity.js'; | ||||
| import {mapToUserDTO} from './user.js'; | ||||
| import {TeacherInvitationDTO} from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import {getTeacherInvitationRepository} from '../data/repositories'; | ||||
| import {Teacher} from '../entities/users/teacher.entity'; | ||||
| import {Class} from '../entities/classes/class.entity'; | ||||
| import {ClassStatus} from "@dwengo-1/common/util/class-join-request"; | ||||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js'; | ||||
| import { mapToUserDTO } from './user.js'; | ||||
| import { TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories'; | ||||
| import { Teacher } from '../entities/users/teacher.entity'; | ||||
| import { Class } from '../entities/classes/class.entity'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): TeacherInvitationDTO { | ||||
|     return { | ||||
|         sender: mapToUserDTO(invitation.sender), | ||||
|         receiver: mapToUserDTO(invitation.receiver), | ||||
|         classId: invitation.class.classId!, | ||||
|         status: invitation.status | ||||
|         status: invitation.status, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  | @ -20,7 +20,7 @@ export function mapToTeacherInvitationDTOIds(invitation: TeacherInvitation): Tea | |||
|         sender: invitation.sender.username, | ||||
|         receiver: invitation.receiver.username, | ||||
|         classId: invitation.class.classId!, | ||||
|         status: invitation.status | ||||
|         status: invitation.status, | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,8 +2,9 @@ import express from 'express'; | |||
| import { | ||||
|     createInvitationHandler, | ||||
|     deleteInvitationHandler, | ||||
|     getAllInvitationsHandler, getInvitationHandler, | ||||
|     updateInvitationHandler | ||||
|     getAllInvitationsHandler, | ||||
|     getInvitationHandler, | ||||
|     updateInvitationHandler, | ||||
| } from '../controllers/teacher-invitations'; | ||||
| 
 | ||||
| const router = express.Router({ mergeParams: true }); | ||||
|  |  | |||
|  | @ -1,12 +1,12 @@ | |||
| import {fetchTeacher} from './teachers'; | ||||
| import {getTeacherInvitationRepository} from '../data/repositories'; | ||||
| import {mapToInvitation, mapToTeacherInvitationDTO} from '../interfaces/teacher-invitation'; | ||||
| import {addClassTeacher, fetchClass} from './classes'; | ||||
| import {TeacherInvitationData, TeacherInvitationDTO} from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import {ConflictException} from '../exceptions/conflict-exception'; | ||||
| import {NotFoundException} from '../exceptions/not-found-exception'; | ||||
| import {TeacherInvitation} from '../entities/classes/teacher-invitation.entity'; | ||||
| import {ClassStatus} from "@dwengo-1/common/util/class-join-request"; | ||||
| import { fetchTeacher } from './teachers'; | ||||
| import { getTeacherInvitationRepository } from '../data/repositories'; | ||||
| import { mapToInvitation, mapToTeacherInvitationDTO } from '../interfaces/teacher-invitation'; | ||||
| import { addClassTeacher, fetchClass } from './classes'; | ||||
| import { TeacherInvitationData, TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { ConflictException } from '../exceptions/conflict-exception'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception'; | ||||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export async function getAllInvitations(username: string, sent: boolean): Promise<TeacherInvitationDTO[]> { | ||||
|     const teacher = await fetchTeacher(username); | ||||
|  |  | |||
|  | @ -5,11 +5,11 @@ import { | |||
|     createInvitationHandler, | ||||
|     deleteInvitationHandler, | ||||
|     getAllInvitationsHandler, | ||||
|     getInvitationHandler | ||||
|     getInvitationHandler, | ||||
| } from '../../src/controllers/teacher-invitations'; | ||||
| import { TeacherInvitationData } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { getClassHandler } from '../../src/controllers/classes'; | ||||
| import {BadRequestException} from "../../src/exceptions/bad-request-exception"; | ||||
| import { BadRequestException } from '../../src/exceptions/bad-request-exception'; | ||||
| 
 | ||||
| describe('Teacher controllers', () => { | ||||
|     let req: Partial<Request>; | ||||
|  | @ -91,8 +91,7 @@ describe('Teacher controllers', () => { | |||
|             params: { no: 'no params' }, | ||||
|         }; | ||||
| 
 | ||||
|         await expect( async () => getInvitationHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(BadRequestException); | ||||
|         await expect(async () => getInvitationHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); | ||||
|     }); | ||||
| 
 | ||||
|     /* | ||||
|  |  | |||
|  | @ -1,36 +1,36 @@ | |||
| import {EntityManager} from '@mikro-orm/core'; | ||||
| import {TeacherInvitation} from '../../../src/entities/classes/teacher-invitation.entity'; | ||||
| import {Teacher} from '../../../src/entities/users/teacher.entity'; | ||||
| import {Class} from '../../../src/entities/classes/class.entity'; | ||||
| import {ClassStatus} from "@dwengo-1/common/util/class-join-request"; | ||||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { TeacherInvitation } from '../../../src/entities/classes/teacher-invitation.entity'; | ||||
| import { Teacher } from '../../../src/entities/users/teacher.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function makeTestTeacherInvitations(em: EntityManager, teachers: Teacher[], classes: Class[]): TeacherInvitation[] { | ||||
|     const teacherInvitation01 = em.create(TeacherInvitation, { | ||||
|         sender: teachers[1], | ||||
|         receiver: teachers[0], | ||||
|         class: classes[1], | ||||
|         status: ClassStatus.Open | ||||
|         status: ClassStatus.Open, | ||||
|     }); | ||||
| 
 | ||||
|     const teacherInvitation02 = em.create(TeacherInvitation, { | ||||
|         sender: teachers[1], | ||||
|         receiver: teachers[2], | ||||
|         class: classes[1], | ||||
|         status: ClassStatus.Open | ||||
|         status: ClassStatus.Open, | ||||
|     }); | ||||
| 
 | ||||
|     const teacherInvitation03 = em.create(TeacherInvitation, { | ||||
|         sender: teachers[2], | ||||
|         receiver: teachers[0], | ||||
|         class: classes[2], | ||||
|         status: ClassStatus.Open | ||||
|         status: ClassStatus.Open, | ||||
|     }); | ||||
| 
 | ||||
|     const teacherInvitation04 = em.create(TeacherInvitation, { | ||||
|         sender: teachers[0], | ||||
|         receiver: teachers[1], | ||||
|         class: classes[0], | ||||
|         status: ClassStatus.Open | ||||
|         status: ClassStatus.Open, | ||||
|     }); | ||||
| 
 | ||||
|     return [teacherInvitation01, teacherInvitation02, teacherInvitation03, teacherInvitation04]; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { UserDTO } from './user'; | ||||
| import {ClassStatus} from "../util/class-join-request"; | ||||
| import { ClassStatus } from '../util/class-join-request'; | ||||
| 
 | ||||
| export interface TeacherInvitationDTO { | ||||
|     sender: string | UserDTO; | ||||
|  |  | |||
		Reference in a new issue
	
	 Lint Action
						Lint Action