HotTRDealsBackend/adapters/responses/comment.adapter.js
2026-01-23 17:28:21 +00:00

30 lines
725 B
JavaScript

function mapCommentToDealCommentResponse(comment) {
return {
id: comment.id,
text: comment.text, // eğer DB'de content ise burada text'e çevir
createdAt: comment.createdAt,
user: {
id: comment.user.id,
username: comment.user.username,
avatarUrl: comment.user.avatarUrl ?? null,
},
}
}
function mapCommentsToDealCommentResponse(comments) {
return comments.map(mapCommentToDealCommentResponse)
}
function mapCommentToUserCommentResponse(c) {
return {
...mapCommentToDealCommentResponse(c),
deal: { id: c.deal.id, title: c.deal.title },
}
}
module.exports = {
mapCommentToDealCommentResponse,
mapCommentsToDealCommentResponse,
mapCommentToUserCommentResponse
}