aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/api/Api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/api/Api.ts')
-rw-r--r--frontend/src/api/Api.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/frontend/src/api/Api.ts b/frontend/src/api/Api.ts
new file mode 100644
index 0000000..2e55ab4
--- /dev/null
+++ b/frontend/src/api/Api.ts
@@ -0,0 +1,56 @@
1import { MapDiscussionCommentContent, MapDiscussionContent, ModMenuContent } from '@customTypes/Content';
2import { delete_token, get_token } from '@api/Auth';
3import { get_user, get_profile, post_profile } from '@api/User';
4import { get_games, get_chapters, get_games_chapters, get_game_maps, get_search } from '@api/Games';
5import { get_official_rankings, get_unofficial_rankings } from '@api/Rankings';
6import { get_map_summary, get_map_leaderboard, get_map_discussions, get_map_discussion, post_map_discussion, post_map_discussion_comment, delete_map_discussion, post_record, delete_map_record } from '@api/Maps';
7import { delete_map_summary, post_map_summary, put_map_image, put_map_summary } from '@api/Mod';
8import { UploadRunContent } from '@customTypes/Content';
9
10// add new api call function entries here
11// example usage: API.get_games();
12export const API = {
13 // Auth
14 get_token: () => get_token(),
15
16 delete_token: () => delete_token(),
17 // User
18 get_user: (user_id: string) => get_user(user_id),
19 get_profile: (token: string) => get_profile(token),
20 post_profile: (token: string) => post_profile(token),
21 // Games
22 get_games: () => get_games(),
23 get_chapters: (chapter_id: string) => get_chapters(chapter_id),
24 get_games_chapters: (game_id: string) => get_games_chapters(game_id),
25 get_game_maps: (game_id: string) => get_game_maps(game_id),
26 get_search: (q: string) => get_search(q),
27 // Rankings
28 get_official_rankings: () => get_official_rankings(),
29 get_unofficial_rankings: () => get_unofficial_rankings(),
30 // Maps
31 get_map_summary: (map_id: string) => get_map_summary(map_id),
32 get_map_leaderboard: (map_id: string) => get_map_leaderboard(map_id),
33 get_map_discussions: (map_id: string) => get_map_discussions(map_id),
34 get_map_discussion: (map_id: string, discussion_id: number) => get_map_discussion(map_id, discussion_id),
35
36 post_map_discussion: (token: string, map_id: string, content: MapDiscussionContent) => post_map_discussion(token, map_id, content),
37 post_map_discussion_comment: (token: string, map_id: string, discussion_id: number, comment: string) => post_map_discussion_comment(token, map_id, discussion_id, comment),
38 post_record: (token: string, run: UploadRunContent) => post_record(token, run),
39
40 delete_map_discussion: (token: string, map_id: string, discussion_id: number) => delete_map_discussion(token, map_id, discussion_id),
41
42 delete_map_record: (token: string, map_id: number, record_id: number) => delete_map_record(token, map_id, record_id),
43 // Mod
44 post_map_summary: (token: string, map_id: string, content: ModMenuContent) => post_map_summary(token, map_id, content),
45
46 put_map_image: (token: string, map_id: string, image: string) => put_map_image(token, map_id, image),
47 put_map_summary: (token: string, map_id: string, content: ModMenuContent) => put_map_summary(token, map_id, content),
48
49 delete_map_summary: (token: string, map_id: string, route_id: number) => delete_map_summary(token, map_id, route_id),
50};
51
52const BASE_API_URL: string = "/api/v1/"
53
54export function url(path: string): string {
55 return BASE_API_URL + path;
56};