-
Notifications
You must be signed in to change notification settings - Fork 2
/
api.js
118 lines (97 loc) · 2.74 KB
/
api.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// projects
export function getProjects(axios, params) {
return axios.get('/projects', { params });
}
export function getFeaturedProjects(axios, limit) {
return axios.$get(`/projects/paginated/1/${limit}`);
}
export function getProjectById(axios, id) {
return axios.get(`/projects/${id}`); // dont filter for data object
}
// dao-proposals
export function getDaoProposals(axios, params) {
return axios.get('/dao-proposals', { params });
}
// fulltext-proposal
export function getFulltextProposalHtml(axios, proposalId) {
return axios.get(`/dao-proposals/${proposalId}/fulltext`);
}
export function getFeaturedDaoProposals(axios, limit) {
return axios.$get(`/dao-proposals/paginated/1/${limit}`);
}
// jobs
export function getJobs(axios) {
return axios.$get('/jobs'); // not implemented yet
}
// posts
export function getPosts(axios, params) {
return axios.get('/posts', { params });
}
// post by id
export function getPostById(axios, id) {
return axios.get(`/posts/${id}`);
}
// landing page
export function getLandingData(axios) {
return axios.get('/pages/index'); // dont filter for data object
}
// dao round
export function getDaoRoundMetrics(axios, params) {
return axios.get('/metrics', { params }); // dont filter for data object
}
// leaderboard
export function getLeaderboard(axios, params) {
return axios.$get('/leaderboard', { params });
}
// account login
export function login(axios, payload) {
return axios.post('/account/login', payload, { withCredentials: true });
}
// account logout
export function logout(axios) {
return axios.post('/account/logout', null, { withCredentials: true });
}
// account retrieval
export function getAccount(axios) {
return axios.get('/account', { withCredentials: true });
}
// update project data
export function updateProject(axios, payload) {
return axios.put('/account/projects', payload, {
withCredentials: true,
});
}
// project creation
export function createProject(axios, payload) {
return axios.post('/account/projects', payload, {
withCredentials: true,
});
}
// post creation
export function createPost(axios, payload) {
return axios.post('/account/posts', payload, {
withCredentials: true,
});
}
// logo upload
export function uploadLogo(axios, file) {
const data = new FormData();
data.append('logo', file);
return axios.$post('/account/logos', data, {
withCredentials: true,
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
// images upload
export function uploadImages(axios, files) {
const data = new FormData();
Array.from(files).forEach((file) => data.append('images', file));
return axios.$post('/account/images', data, {
withCredentials: true,
headers: {
'Content-Type': 'multipart/form-data',
},
});
}