-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
methods.ts
39 lines (31 loc) · 1.17 KB
/
methods.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
import {
SettingsResponse,
TeamResponse,
ServerResponse, IssuesResponse
} from "~/config/types";
import { RPCClient } from "~/app/ws/RPCClient";
const settings = (rpc: RPCClient) => () => rpc.call('get:api/settings')
.then((response: ServerResponse<SettingsResponse>) => response.data);
const team = (rpc: RPCClient) => () => rpc.call('get:api/team')
.then((response: ServerResponse<TeamResponse>) => response.data.data);
const issuesForContributors = (rpc: RPCClient) => () => rpc.call('get:api/issues/for-contributors')
.then((response: ServerResponse<IssuesResponse>) => response.data.data);
const like = (rpc: RPCClient) => (key: string) => rpc.call('post:api/like', {key});
const callExampleAction = (host: string) => (action: string) => {
action = action.toLowerCase();
const path: string = action === 'profiler:report' ? 'example/call/profiler' : 'example/call';
return useFetch(`${host}/${path}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({action})
})
}
export default {
settings,
team,
callExampleAction,
issuesForContributors,
like
}