feat: add, delete student route met user logic + .js in files
This commit is contained in:
parent
e0a5596994
commit
ecad27ea4d
29 changed files with 301 additions and 159 deletions
30
backend/src/interfaces/user.ts
Normal file
30
backend/src/interfaces/user.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { User } from "../entities/users/user.entity.js";
|
||||
|
||||
export interface UserDTO {
|
||||
id?: string,
|
||||
username: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
endpoints?: {
|
||||
self: string;
|
||||
classes: string;
|
||||
questions: string;
|
||||
invitations: string;
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToUserDTO(user: User): UserDTO {
|
||||
return {
|
||||
id: user.username,
|
||||
username: user.username,
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
};
|
||||
}
|
||||
|
||||
export function mapToUser<T extends User>(userData: UserDTO, userInstance: T): T {
|
||||
userInstance.username = userData.username;
|
||||
userInstance.firstName = userData.firstName;
|
||||
userInstance.lastName = userData.lastName;
|
||||
return userInstance;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue