forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiService.js
More file actions
51 lines (39 loc) · 1.55 KB
/
apiService.js
File metadata and controls
51 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import apiClient from "./apiClient";
export const postApi = {
// 모든 포스트 목록 조회 (검색 파라미터 없음)
getPosts: () => apiClient.get("/posts"),
// 특정 포스트 조회
getPost: (postId) => apiClient.get(`/posts/${postId}`),
// 새 포스트 생성
createPost: (content, username) =>
apiClient.post("/posts", { username, content }),
// 포스트 수정 (PATCH)
updatePost: (postId, content, username) =>
apiClient.patch(`/posts/${postId}`, { username, content }),
// 포스트 삭제
deletePost: (postId) =>
apiClient.delete(`/posts/${postId}`),
// 포스트 좋아요 (POST)
likePost: (postId, username) =>
apiClient.post(`/posts/${postId}/likes`, { username }),
// 포스트 좋아요 취소 (DELETE)
unlikePost: (postId) =>
apiClient.delete(`/posts/${postId}/likes`),
};
export const commentApi = {
// 포스트의 댓글 목록 조회
getComments: (postId) =>
apiClient.get(`/posts/${postId}/comments`),
// 포스트에 댓글 작성
createComment: (postId, content, username) =>
apiClient.post(`/posts/${postId}/comments`, { username, content }),
// 특정 댓글 조회
getComment: (postId, commentId) =>
apiClient.get(`/posts/${postId}/comments/${commentId}`),
// 특정 댓글 수정 (PATCH)
updateComment: (postId, commentId, content, username) =>
apiClient.patch(`/posts/${postId}/comments/${commentId}`, { username, content }),
// 특정 댓글 삭제
deleteComment: (postId, commentId) =>
apiClient.delete(`/posts/${postId}/comments/${commentId}`),
};