-
Notifications
You must be signed in to change notification settings - Fork 0
/
endpoints.ts
86 lines (76 loc) · 2.24 KB
/
endpoints.ts
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
export type Endpoint = {
url: string;
method: "get" | "post" | "delete";
auth?: boolean;
};
export enum Endpoints {
healthz = "healthz",
signin = "signin",
signup = "signup",
getUser = "getUser",
getSignedInUser = "getSignedInUser",
getUserProfile = "getUserProfile",
createPost = "createPost",
listPosts = "listPosts",
getPost = "getPost",
deletePost = "deletePost",
createLike = "createLike",
countLikes = "countLikes",
deleteLike = "deleteLike",
checkLikeExist = "checkLikeExist",
createComment = "createComment",
listComments = "listComments",
deleteComment = "deleteComment",
countComments = "countComments",
}
export const ENDPOINT_CONFIGS: { [key in Endpoints]: Endpoint } = {
[Endpoints.healthz]: { method: "get", url: "/api/v1/healthz" },
[Endpoints.signin]: { method: "post", url: "/api/v1/signin" },
[Endpoints.signup]: { method: "post", url: "/api/v1/signup" },
[Endpoints.getSignedInUser]: {
method: "get",
url: "/api/v1/user/",
auth: true,
},
[Endpoints.getUser]: { method: "get", url: "/api/v1/user/:userId" },
[Endpoints.getUserProfile]: { method: "get", url: "/api/v1/profile/:userId" },
[Endpoints.listPosts]: { method: "get", url: "/api/v1/posts" },
[Endpoints.getPost]: { method: "get", url: "/api/v1/posts/:id" },
[Endpoints.createPost]: { method: "post", url: "/api/v1/posts", auth: true },
[Endpoints.deletePost]: {
method: "delete",
url: "/api/v1/posts/:id",
auth: true,
},
[Endpoints.checkLikeExist]: {
method: "get",
url: "/api/v1/likes/:postId",
auth: true,
},
[Endpoints.countLikes]: { method: "get", url: "/api/v1/likes/count/:postId" },
[Endpoints.createLike]: {
method: "post",
url: "/api/v1/likes/:postId",
auth: true,
},
[Endpoints.deleteLike]: {
method: "delete",
url: "/api/v1/likes/:postId",
auth: true,
},
[Endpoints.countComments]: {
method: "get",
url: "/api/v1/comments/count/:postId",
},
[Endpoints.listComments]: { method: "get", url: "/api/v1/comments/:postId" },
[Endpoints.createComment]: {
method: "post",
url: "/api/v1/comments/:postId",
auth: true,
},
[Endpoints.deleteComment]: {
method: "delete",
url: "/api/v1/comments/:commentId",
auth: true,
},
};