Skip to content

Commit 3f72f45

Browse files
committed
feat: add CommentPresentation interface and update getComments return type
1 parent ccfa81f commit 3f72f45

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/backend/models/domain-models.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ export interface Comment {
139139
created_at: Date;
140140
}
141141

142+
export interface CommentPresentation {
143+
id: string;
144+
body?: string;
145+
level?: number;
146+
created_at?: Date;
147+
author?: {
148+
id: string;
149+
name: string;
150+
username: string;
151+
email: string;
152+
};
153+
replies?: CommentPresentation[];
154+
}
155+
142156
export type REACTION_TYPE =
143157
| "LOVE"
144158
| "UNICORN"

src/backend/services/comment.action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { authID } from "./session.actions";
44
import { ActionException } from "./RepositoryException";
55
import { persistenceRepository } from "../persistence/persistence-repositories";
66
import { eq } from "sqlkit";
7+
import { CommentPresentation } from "../models/domain-models";
78

89
const sql = String.raw;
910

1011
export const getComments = async (
1112
_input: z.infer<typeof CommentActionInput.getComments>
12-
) => {
13+
): Promise<CommentPresentation[]> => {
1314
const input = CommentActionInput.getComments.parse(_input);
1415

1516
const query = sql`

0 commit comments

Comments
 (0)