refactor(common): AnswerDTO

This commit is contained in:
Tibo De Peuter 2025-03-31 18:40:19 +02:00
parent 8bf927d1c9
commit 6c9c8d782d
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
2 changed files with 19 additions and 16 deletions

View file

@ -1,14 +1,7 @@
import { mapToUserDTO, UserDTO } from './user.js';
import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from './question.js';
import { mapToUserDTO } from './user.js';
import { mapToQuestionDTO, mapToQuestionId } from './question.js';
import { Answer } from '../entities/questions/answer.entity.js';
export interface AnswerDTO {
author: UserDTO;
toQuestion: QuestionDTO;
sequenceNumber: number;
timestamp: string;
content: string;
}
import { AnswerDTO, AnswerId } from 'dwengo-1-common/src/interfaces/answer';
/**
* Convert a Question entity to a DTO format.
@ -23,12 +16,6 @@ export function mapToAnswerDTO(answer: Answer): AnswerDTO {
};
}
export interface AnswerId {
author: string;
toQuestion: QuestionId;
sequenceNumber: number;
}
export function mapToAnswerId(answer: AnswerDTO): AnswerId {
return {
author: answer.author.username,

16
common/src/interfaces/answer.d.ts vendored Normal file
View file

@ -0,0 +1,16 @@
import { UserDTO } from 'dwengo-1-backend/src/interfaces/user.js'
import { QuestionDTO } from 'dwengo-1-backend/src/interfaces/question.js'
export interface AnswerDTO {
author: UserDTO;
toQuestion: QuestionDTO;
sequenceNumber: number;
timestamp: string;
content: string;
}
export interface AnswerId {
author: string;
toQuestion: QuestionId;
sequenceNumber: number;
}