Skip to content

Commit 5a6e5ef

Browse files
committed
Implement API endpoints
1 parent c22b4d3 commit 5a6e5ef

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/apis.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
const isProduction = process.env.NODE_ENV === 'production';
22
const mockPath = `${process.env.PUBLIC_URL}/__mocks__/apiRequests`;
33

4+
export const domain = window.location.hostname;
5+
46
export const getAppData = isProduction
5-
? 'localhost/getAppData'
7+
? `//${domain}/get-app-data.php`
68
: `${mockPath}/getAppData.json`;
79

810
export const getDockerData = isProduction
9-
? 'localhost/getDockerData'
11+
? `//${domain}/get-docker-data.php`
1012
: `${mockPath}/getDockerData.json`;
1113

1214
export const getMails = isProduction
13-
? 'localhost/getMails'
15+
? `//${domain}/get-mails.php`
1416
: `${mockPath}/getMails.json`;
1517

1618
export const makeGetContainerData = (id: string) =>
1719
isProduction
18-
? `localhost/getContainerData/${id}`
20+
? `//${domain}/get-container-data.php?id=${id}`
1921
: `${mockPath}/containerData/${id}.json`;
2022

2123
export const makeGetToolsData = (id: string) =>
2224
isProduction
23-
? `localhost/getToolsData/${id}`
25+
? `//${domain}/get-tools.php?id=${id}`
2426
: `${mockPath}/tools/${id}.json`;
2527

2628
export const getVhosts = isProduction
27-
? 'localhost/getVhosts'
29+
? `//${domain}/get-vhosts.php`
2830
: `${mockPath}/getVhosts.json`;
2931

3032
export const makeGetVhostDirectory = (id: string) =>
3133
isProduction
32-
? `localhost/vhosts/directory/${id}`
34+
? `//${domain}/get-vhost-dir.php?id=${id}`
3335
: `${mockPath}/vhosts/directory/${id}.json`;
3436

35-
export const makeGetVhostsDomain = (id: string) =>
37+
export const makeGetVhostsDomain = (id: string, tld_suffix: string) =>
3638
isProduction
37-
? `localhost/vhosts/domain/${id}`
39+
? `//${id}.${tld_suffix}/devilbox-api/status.json`
3840
: `${mockPath}/vhosts/domain/${id}.json`;

src/app/pages/Vhosts/saga.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
makeVhostsSelector,
77
makeDomainErrorSelector,
88
makeDirectoryErrorSelector,
9+
makeTldSuffixSelector,
910
} from './selectors';
1011
import {
1112
getVhosts as GET_VHOSTS_API,
@@ -39,8 +40,10 @@ function* fetchDirectory(vhostId: string) {
3940
}
4041

4142
function* fetchDomain(vhostId: string) {
43+
const tldSuffix = yield select(makeTldSuffixSelector);
44+
4245
try {
43-
yield axios.get(makeGetVhostsDomain(vhostId), { timeout: 1000 });
46+
yield axios.get(makeGetVhostsDomain(vhostId, tldSuffix), { timeout: 1000 });
4447
} catch (e) {
4548
const selector = makeDomainErrorSelector(vhostId);
4649
const error = yield select(selector);

0 commit comments

Comments
 (0)