Last active
November 4, 2025 23:17
-
-
Save tanat/61b03011a1e2bb689a83aca10e37ccfc to your computer and use it in GitHub Desktop.
gameApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createApi } from '@reduxjs/toolkit/query/react'; | |
| import { baseQuery } from '@shared/api'; | |
| import { Contest } from '@shared/types'; | |
| export const contestApi = createApi({ | |
| reducerPath: 'contestApi', | |
| baseQuery, | |
| tagTypes: ['Contest', 'Leaderboard'], | |
| endpoints: (builder) => ({ | |
| // Get contest by ID | |
| getContest: builder.query<Contest, number>({ | |
| query: (id) => ({ | |
| url: `v2/contests/${id}/`, | |
| method: 'GET', | |
| }), | |
| providesTags: ['Contest'], | |
| }), | |
| // Get leaderboard | |
| getLeaderboard: builder.query<any[], string>({ | |
| query: (date) => ({ | |
| url: `api/v1/leaderboard/?date=${date}`, | |
| method: 'GET', | |
| }), | |
| providesTags: ['Leaderboard'], | |
| }), | |
| }), | |
| }); | |
| export const { | |
| useGetContestQuery, | |
| useGetLeaderboardQuery, | |
| useLazyGetLeaderboardQuery, | |
| } = contestApi; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment