feat: 게시글 댓글 등록 작업

This commit is contained in:
2025-05-09 17:25:59 +09:00
parent e675e4cff6
commit 697ac34f65
10 changed files with 314 additions and 42 deletions
@@ -0,0 +1,31 @@
import { client } from "@/shared/api";
import { ENDPOINT } from "@/shared/config";
import {
commentFormSchema,
type Comment,
type CommentService,
type CommentList,
type CommentParams,
type CommentFormData,
} from "../model/comment-interface";
export class CommentApiService implements CommentService {
public async getComments(params: CommentParams): Promise<CommentList> {
const response = await client.get<CommentList>(
`${ENDPOINT.BOARD_SERVICE.POSTS_COMMENTS}`,
{ params },
);
return response.data;
}
public async createComment(data: CommentFormData): Promise<Comment> {
const validatedData = commentFormSchema.parse(data);
const response = await client.post<Comment>(
`${ENDPOINT.BOARD_SERVICE.POSTS_COMMENTS}`,
validatedData,
);
return response.data;
}
}
export const CommentApi = new CommentApiService();