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