Skip to content

Commit 6b3c74b

Browse files
committed
fix: incorrect api urls (missing api version)
1 parent 4206833 commit 6b3c74b

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/ui/services/config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,31 @@ import { API_BASE } from '../apiBase';
33
import { FormQuestion } from '../views/PushDetails/components/AttestationForm';
44
import { UIRouteAuth } from '../../config/generated/config';
55

6+
const API_V1_BASE = `${API_BASE}/api/v1`;
7+
68
const setAttestationConfigData = async (setData: (data: FormQuestion[]) => void) => {
7-
const url = new URL(`${API_BASE}/config/attestation`);
9+
const url = new URL(`${API_V1_BASE}/config/attestation`);
810
await axios(url.toString()).then((response) => {
911
setData(response.data.questions);
1012
});
1113
};
1214

1315
const setURLShortenerData = async (setData: (data: string) => void) => {
14-
const url = new URL(`${API_BASE}/config/urlShortener`);
16+
const url = new URL(`${API_V1_BASE}/config/urlShortener`);
1517
await axios(url.toString()).then((response) => {
1618
setData(response.data);
1719
});
1820
};
1921

2022
const setEmailContactData = async (setData: (data: string) => void) => {
21-
const url = new URL(`${API_BASE}/config/contactEmail`);
23+
const url = new URL(`${API_V1_BASE}/config/contactEmail`);
2224
await axios(url.toString()).then((response) => {
2325
setData(response.data);
2426
});
2527
};
2628

2729
const setUIRouteAuthData = async (setData: (data: UIRouteAuth) => void) => {
28-
const url = new URL(`${API_BASE}/config/uiRouteAuth`);
30+
const url = new URL(`${API_V1_BASE}/config/uiRouteAuth`);
2931
await axios(url.toString()).then((response) => {
3032
setData(response.data);
3133
});

src/ui/services/git-push.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import axios from 'axios';
22
import { getAxiosConfig, processAuthError } from './auth';
33
import { API_BASE } from '../apiBase';
44

5+
const API_V1_BASE = `${API_BASE}/api/v1`;
6+
57
const getPush = async (
68
id: string,
79
setIsLoading: (isLoading: boolean) => void,
810
setData: (data: any) => void,
911
setAuth: (auth: boolean) => void,
1012
setIsError: (isError: boolean) => void,
1113
): Promise<void> => {
12-
const url = `${API_BASE}/push/${id}`;
14+
const url = `${API_V1_BASE}/push/${id}`;
1315
setIsLoading(true);
1416

1517
try {
@@ -38,7 +40,7 @@ const getPushes = async (
3840
rejected: false,
3941
},
4042
): Promise<void> => {
41-
const url = new URL(`${API_BASE}/push`);
43+
const url = new URL(`${API_V1_BASE}/push`);
4244
url.search = new URLSearchParams(query as any).toString();
4345

4446
setIsLoading(true);
@@ -67,7 +69,7 @@ const authorisePush = async (
6769
setUserAllowedToApprove: (userAllowedToApprove: boolean) => void,
6870
attestation: Array<{ label: string; checked: boolean }>,
6971
): Promise<void> => {
70-
const url = `${API_BASE}/push/${id}/authorise`;
72+
const url = `${API_V1_BASE}/push/${id}/authorise`;
7173
let errorMsg = '';
7274
let isUserAllowedToApprove = true;
7375
await axios
@@ -95,7 +97,7 @@ const rejectPush = async (
9597
setMessage: (message: string) => void,
9698
setUserAllowedToReject: (userAllowedToReject: boolean) => void,
9799
): Promise<void> => {
98-
const url = `${API_BASE}/push/${id}/reject`;
100+
const url = `${API_V1_BASE}/push/${id}/reject`;
99101
let errorMsg = '';
100102
let isUserAllowedToReject = true;
101103
await axios.post(url, {}, getAxiosConfig()).catch((error: any) => {

src/ui/services/repo.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { getAxiosConfig, processAuthError } from './auth.js';
33
import { API_BASE } from '../apiBase';
44
import { RepositoryData, RepositoryDataWithId } from '../views/RepoList/Components/NewRepo';
55

6+
const API_V1_BASE = `${API_BASE}/api/v1`;
7+
68
const canAddUser = (repoId: string, user: string, action: string) => {
7-
const url = new URL(`${API_BASE}/repo/${repoId}`);
9+
const url = new URL(`${API_V1_BASE}/repo/${repoId}`);
810
return axios
911
.get(url.toString(), getAxiosConfig())
1012
.then((response) => {
@@ -35,7 +37,7 @@ const getRepos = async (
3537
setErrorMessage: (errorMessage: string) => void,
3638
query: Record<string, boolean> = {},
3739
): Promise<void> => {
38-
const url = new URL(`${API_BASE}/repo`);
40+
const url = new URL(`${API_V1_BASE}/repo`);
3941
url.search = new URLSearchParams(query as any).toString();
4042
setIsLoading(true);
4143
await axios(url.toString(), getAxiosConfig())
@@ -66,7 +68,7 @@ const getRepo = async (
6668
setIsError: (isError: boolean) => void,
6769
id: string,
6870
): Promise<void> => {
69-
const url = new URL(`${API_BASE}/repo/${id}`);
71+
const url = new URL(`${API_V1_BASE}/repo/${id}`);
7072
setIsLoading(true);
7173
await axios(url.toString(), getAxiosConfig())
7274
.then((response) => {
@@ -88,7 +90,7 @@ const getRepo = async (
8890
const addRepo = async (
8991
data: RepositoryData,
9092
): Promise<{ success: boolean; message?: string; repo: RepositoryDataWithId | null }> => {
91-
const url = new URL(`${API_BASE}/repo`);
93+
const url = new URL(`${API_V1_BASE}/repo`);
9294

9395
try {
9496
const response = await axios.post(url.toString(), data, getAxiosConfig());
@@ -108,7 +110,7 @@ const addRepo = async (
108110
const addUser = async (repoId: string, user: string, action: string): Promise<void> => {
109111
const canAdd = await canAddUser(repoId, user, action);
110112
if (canAdd) {
111-
const url = new URL(`${API_BASE}/repo/${repoId}/user/${action}`);
113+
const url = new URL(`${API_V1_BASE}/repo/${repoId}/user/${action}`);
112114
const data = { username: user };
113115
await axios.patch(url.toString(), data, getAxiosConfig()).catch((error: any) => {
114116
console.log(error.response.data.message);
@@ -121,7 +123,7 @@ const addUser = async (repoId: string, user: string, action: string): Promise<vo
121123
};
122124

123125
const deleteUser = async (user: string, repoId: string, action: string): Promise<void> => {
124-
const url = new URL(`${API_BASE}/repo/${repoId}/user/${action}/${user}`);
126+
const url = new URL(`${API_V1_BASE}/repo/${repoId}/user/${action}/${user}`);
125127

126128
await axios.delete(url.toString(), getAxiosConfig()).catch((error: any) => {
127129
console.log(error.response.data.message);
@@ -130,7 +132,7 @@ const deleteUser = async (user: string, repoId: string, action: string): Promise
130132
};
131133

132134
const deleteRepo = async (repoId: string): Promise<void> => {
133-
const url = new URL(`${API_BASE}/repo/${repoId}/delete`);
135+
const url = new URL(`${API_V1_BASE}/repo/${repoId}/delete`);
134136

135137
await axios.delete(url.toString(), getAxiosConfig()).catch((error: any) => {
136138
console.log(error.response.data.message);

0 commit comments

Comments
 (0)