Skip to content

Commit cac885b

Browse files
authored
Merge pull request #61 from devilbox/apis
Implement API endpoints
2 parents c22b4d3 + 40dc461 commit cac885b

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/apis.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
const isProduction = process.env.NODE_ENV === 'production';
22
const mockPath = `${process.env.PUBLIC_URL}/__mocks__/apiRequests`;
33

4+
const {
5+
location: { hostname: domain },
6+
} = window;
7+
48
export const getAppData = isProduction
5-
? 'localhost/getAppData'
9+
? `//${domain}/get-app-data.php`
610
: `${mockPath}/getAppData.json`;
711

812
export const getDockerData = isProduction
9-
? 'localhost/getDockerData'
13+
? `//${domain}/get-docker-data.php`
1014
: `${mockPath}/getDockerData.json`;
1115

1216
export const getMails = isProduction
13-
? 'localhost/getMails'
17+
? `//${domain}/get-mails.php`
1418
: `${mockPath}/getMails.json`;
1519

1620
export const makeGetContainerData = (id: string) =>
1721
isProduction
18-
? `localhost/getContainerData/${id}`
22+
? `//${domain}/get-container-data.php?id=${id}`
1923
: `${mockPath}/containerData/${id}.json`;
2024

2125
export const makeGetToolsData = (id: string) =>
2226
isProduction
23-
? `localhost/getToolsData/${id}`
27+
? `//${domain}/get-tools.php?id=${id}`
2428
: `${mockPath}/tools/${id}.json`;
2529

2630
export const getVhosts = isProduction
27-
? 'localhost/getVhosts'
31+
? `//${domain}/get-vhosts.php`
2832
: `${mockPath}/getVhosts.json`;
2933

3034
export const makeGetVhostDirectory = (id: string) =>
3135
isProduction
32-
? `localhost/vhosts/directory/${id}`
36+
? `//${domain}/get-vhost-dir.php?id=${id}`
3337
: `${mockPath}/vhosts/directory/${id}.json`;
3438

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

src/app/pages/Vhosts/saga.ts

+4-1
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)