mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed paths to match refactored backend
This commit is contained in:
parent
1745cc636d
commit
2f6207feaa
2 changed files with 58 additions and 35 deletions
|
@ -38,7 +38,10 @@ export type ApiGetNodeCommentsRequest = {
|
||||||
take?: number;
|
take?: number;
|
||||||
skip?: number;
|
skip?: number;
|
||||||
};
|
};
|
||||||
export type ApiGetNodeCommentsResponse = { comments: IComment[]; comment_count: number };
|
export type ApiGetNodeCommentsResponse = {
|
||||||
|
comments: IComment[];
|
||||||
|
comment_count: number;
|
||||||
|
};
|
||||||
|
|
||||||
export const apiPostNode = ({ node }: ApiPostNodeRequest) =>
|
export const apiPostNode = ({ node }: ApiPostNodeRequest) =>
|
||||||
api.post<ApiPostNodeResult>(API.NODE.SAVE, node).then(cleanResult);
|
api.post<ApiPostNodeResult>(API.NODE.SAVE, node).then(cleanResult);
|
||||||
|
@ -66,11 +69,14 @@ export const getNodeDiff = ({
|
||||||
})
|
})
|
||||||
.then(cleanResult);
|
.then(cleanResult);
|
||||||
|
|
||||||
export const apiGetNode = ({ id }: ApiGetNodeRequest, config?: AxiosRequestConfig) =>
|
export const apiGetNode = (
|
||||||
|
{ id }: ApiGetNodeRequest,
|
||||||
|
config?: AxiosRequestConfig,
|
||||||
|
) =>
|
||||||
api
|
api
|
||||||
.get<ApiGetNodeResponse>(API.NODE.GET_NODE(id), config)
|
.get<ApiGetNodeResponse>(API.NODE.GET_NODE(id), config)
|
||||||
.then(cleanResult)
|
.then(cleanResult)
|
||||||
.then(data => ({ node: data.node, last_seen: data.last_seen }));
|
.then((data) => ({ node: data.node, last_seen: data.last_seen }));
|
||||||
|
|
||||||
export const apiGetNodeWithCancel = ({ id }: ApiGetNodeRequest) => {
|
export const apiGetNodeWithCancel = ({ id }: ApiGetNodeRequest) => {
|
||||||
const cancelToken = axios.CancelToken.source();
|
const cancelToken = axios.CancelToken.source();
|
||||||
|
@ -93,7 +99,9 @@ export const apiGetNodeComments = ({
|
||||||
skip = 0,
|
skip = 0,
|
||||||
}: ApiGetNodeCommentsRequest) =>
|
}: ApiGetNodeCommentsRequest) =>
|
||||||
api
|
api
|
||||||
.get<ApiGetNodeCommentsResponse>(API.NODE.COMMENT(id), { params: { take, skip } })
|
.get<ApiGetNodeCommentsResponse>(API.NODE.COMMENT(id), {
|
||||||
|
params: { take, skip },
|
||||||
|
})
|
||||||
.then(cleanResult);
|
.then(cleanResult);
|
||||||
|
|
||||||
export const apiGetNodeRelated = ({ id }: ApiGetNodeRelatedRequest) =>
|
export const apiGetNodeRelated = ({ id }: ApiGetNodeRelatedRequest) =>
|
||||||
|
@ -105,20 +113,32 @@ export const apiPostNodeTags = ({ id, tags }: ApiPostNodeTagsRequest) =>
|
||||||
.then(cleanResult);
|
.then(cleanResult);
|
||||||
|
|
||||||
export const apiDeleteNodeTag = ({ id, tagId }: ApiDeleteNodeTagsRequest) =>
|
export const apiDeleteNodeTag = ({ id, tagId }: ApiDeleteNodeTagsRequest) =>
|
||||||
api.delete<ApiDeleteNodeTagsResult>(API.NODE.DELETE_TAG(id, tagId)).then(cleanResult);
|
api
|
||||||
|
.delete<ApiDeleteNodeTagsResult>(API.NODE.DELETE_TAG(id, tagId))
|
||||||
|
.then(cleanResult);
|
||||||
|
|
||||||
export const apiPostNodeLike = ({ id }: ApiPostNodeLikeRequest) =>
|
export const apiPostNodeLike = ({ id }: ApiPostNodeLikeRequest) =>
|
||||||
api.post<ApiPostNodeLikeResult>(API.NODE.POST_LIKE(id)).then(cleanResult);
|
api.post<ApiPostNodeLikeResult>(API.NODE.POST_LIKE(id)).then(cleanResult);
|
||||||
|
|
||||||
export const apiPostNodeHeroic = ({ id }: ApiPostNodeHeroicRequest) =>
|
export const apiPostNodeHeroic = ({ id }: ApiPostNodeHeroicRequest) =>
|
||||||
api.post<ApiPostNodeHeroicResponse>(API.NODE.POST_HEROIC(id)).then(cleanResult);
|
api
|
||||||
|
.post<ApiPostNodeHeroicResponse>(API.NODE.POST_HEROIC(id))
|
||||||
|
.then(cleanResult);
|
||||||
|
|
||||||
export const apiLockNode = ({ id, is_locked }: ApiLockNodeRequest) =>
|
export const apiLockNode = ({ id, is_locked }: ApiLockNodeRequest) =>
|
||||||
api
|
api
|
||||||
.post<ApiLockNodeResult>(API.NODE.POST_LOCK(id), { is_locked })
|
.post<ApiLockNodeResult>(API.NODE.POST_LOCK(id), { is_locked })
|
||||||
.then(cleanResult);
|
.then(cleanResult);
|
||||||
|
|
||||||
export const apiLockComment = ({ id, isLocked, nodeId }: ApiLockCommentRequest) =>
|
export const apiLockComment = ({
|
||||||
|
id,
|
||||||
|
isLocked,
|
||||||
|
nodeId,
|
||||||
|
}: ApiLockCommentRequest) =>
|
||||||
api
|
api
|
||||||
.post<ApiLockcommentResult>(API.NODE.LOCK_COMMENT(nodeId, id), { is_locked: isLocked })
|
.delete<ApiLockcommentResult>(API.NODE.LOCK_COMMENT(nodeId, id), {
|
||||||
|
params: {
|
||||||
|
is_locked: isLocked,
|
||||||
|
},
|
||||||
|
})
|
||||||
.then(cleanResult);
|
.then(cleanResult);
|
||||||
|
|
|
@ -5,15 +5,17 @@ import { CONFIG } from '~/utils/config';
|
||||||
export const API = {
|
export const API = {
|
||||||
BASE: CONFIG.apiHost,
|
BASE: CONFIG.apiHost,
|
||||||
USER: {
|
USER: {
|
||||||
LOGIN: '/user/login',
|
LOGIN: '/users/login',
|
||||||
OAUTH_WINDOW: (provider: OAuthProvider) => `${CONFIG.apiHost}oauth/${provider}/redirect`,
|
OAUTH_WINDOW: (provider: OAuthProvider) =>
|
||||||
ME: '/user/',
|
`${CONFIG.apiHost}oauth/${provider}/redirect`,
|
||||||
PROFILE: (username: string) => `/user/user/${username}/profile`,
|
ME: '/users/',
|
||||||
MESSAGES: (username: string) => `/user/user/${username}/messages`,
|
PROFILE: (username: string) => `/users/user/${username}/profile`,
|
||||||
MESSAGE_SEND: (username: string) => `/user/user/${username}/messages`,
|
MESSAGES: (username: string) => `/users/user/${username}/messages`,
|
||||||
MESSAGE_DELETE: (username: string, id: number) => `/user/user/${username}/messages/${id}`,
|
MESSAGE_SEND: (username: string) => `/users/user/${username}/messages`,
|
||||||
GET_UPDATES: '/user/updates',
|
MESSAGE_DELETE: (username: string, id: number) =>
|
||||||
REQUEST_CODE: (code?: string) => `/user/restore/${code || ''}`,
|
`/users/user/${username}/messages/${id}`,
|
||||||
|
GET_UPDATES: '/users/updates',
|
||||||
|
REQUEST_CODE: (code?: string) => `/users/restore/${code || ''}`,
|
||||||
UPLOAD: (target, type) => `/upload/${target}/${type}`,
|
UPLOAD: (target, type) => `/upload/${target}/${type}`,
|
||||||
|
|
||||||
GET_SOCIALS: '/oauth/',
|
GET_SOCIALS: '/oauth/',
|
||||||
|
@ -22,21 +24,22 @@ export const API = {
|
||||||
LOGIN_WITH_SOCIAL: `/oauth/login`,
|
LOGIN_WITH_SOCIAL: `/oauth/login`,
|
||||||
},
|
},
|
||||||
NODE: {
|
NODE: {
|
||||||
SAVE: '/node/',
|
SAVE: '/nodes/',
|
||||||
GET: '/node/',
|
GET_DIFF: '/nodes/',
|
||||||
GET_DIFF: '/flow/diff',
|
GET_NODE: (id: number | string) => `/nodes/${id}`,
|
||||||
GET_NODE: (id: number | string) => `/node/${id}`,
|
|
||||||
|
|
||||||
COMMENT: (id: INode['id'] | string) => `/node/${id}/comment`,
|
RELATED: (id: INode['id']) => `/nodes/${id}/related`,
|
||||||
RELATED: (id: INode['id']) => `/node/${id}/related`,
|
UPDATE_TAGS: (id: INode['id']) => `/nodes/${id}/tags`,
|
||||||
UPDATE_TAGS: (id: INode['id']) => `/node/${id}/tags`,
|
DELETE_TAG: (id: INode['id'], tagId: ITag['ID']) =>
|
||||||
DELETE_TAG: (id: INode['id'], tagId: ITag['ID']) => `/node/${id}/tags/${tagId}`,
|
`/nodes/${id}/tags/${tagId}`,
|
||||||
POST_LIKE: (id: INode['id']) => `/node/${id}/like`,
|
POST_LIKE: (id: INode['id']) => `/nodes/${id}/like`,
|
||||||
POST_HEROIC: (id: INode['id']) => `/node/${id}/heroic`,
|
POST_HEROIC: (id: INode['id']) => `/nodes/${id}/heroic`,
|
||||||
POST_LOCK: (id: INode['id']) => `/node/${id}/lock`,
|
POST_LOCK: (id: INode['id']) => `/nodes/${id}/lock`,
|
||||||
|
SET_CELL_VIEW: (id: INode['id']) => `/nodes/${id}/cell-view`,
|
||||||
|
|
||||||
|
COMMENT: (id: INode['id'] | string) => `/nodes/${id}/comment`,
|
||||||
LOCK_COMMENT: (id: INode['id'], comment_id: IComment['id']) =>
|
LOCK_COMMENT: (id: INode['id'], comment_id: IComment['id']) =>
|
||||||
`/node/${id}/comment/${comment_id}/lock`,
|
`/nodes/${id}/comment/${comment_id}`,
|
||||||
SET_CELL_VIEW: (id: INode['id']) => `/node/${id}/cell-view`,
|
|
||||||
},
|
},
|
||||||
SEARCH: {
|
SEARCH: {
|
||||||
NODES: '/search/nodes',
|
NODES: '/search/nodes',
|
||||||
|
@ -49,12 +52,12 @@ export const API = {
|
||||||
GITHUB_ISSUES: 'https://api.github.com/repos/muerwre/vault-frontend/issues',
|
GITHUB_ISSUES: 'https://api.github.com/repos/muerwre/vault-frontend/issues',
|
||||||
},
|
},
|
||||||
TAG: {
|
TAG: {
|
||||||
NODES: `/tag/nodes`,
|
NODES: `/tags/nodes`,
|
||||||
AUTOCOMPLETE: `/tag/autocomplete`,
|
AUTOCOMPLETE: `/tags/autocomplete`,
|
||||||
},
|
},
|
||||||
LAB: {
|
LAB: {
|
||||||
NODES: `/lab/`,
|
NODES: `/nodes/lab`,
|
||||||
STATS: '/lab/stats',
|
STATS: '/nodes/lab/stats',
|
||||||
UPDATES: '/lab/updates',
|
UPDATES: '/nodes/lab/updates',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue