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
|
import fetchAbsolute from 'fetch-absolute';
import {
API_URL,
CONFIG,
SECRET_KEY,
SERVER_NAME,
SETUP_CHECK,
CERT_PATHS,
TEST_PORTS,
START,
} from './constants';
const fetchAbs = fetchAbsolute(fetch)(API_URL)
export const getServerName = () =>
fetchAbs(SERVER_NAME)
.then(res => res.json())
export const postServerName = (servername, consent) =>
fetchAbs(
SERVER_NAME,
{
method: 'POST',
body: JSON.stringify({
"server_name": servername,
"report_stats": consent,
}),
},
)
export const postCertPaths = (certPath, certKeyPath) =>
fetchAbs(
CERT_PATHS,
{
method: 'POST',
body: JSON.stringify({
// eslint-disable-next-line camelcase
cert_path: certPath,
// eslint-disable-next-line camelcase
cert_key_path: certKeyPath,
}),
},
).then(res => res.json())
export const postCerts = (cert, certKey) =>
fetchAbs(
CERT_PATHS,
{
method: 'POST',
body: JSON.stringify({
cert,
// eslint-disable-next-line camelcase
cert_key: certKey,
}),
},
)
export const testPorts = (ports) =>
fetchAbs(
TEST_PORTS,
{
method: 'POST',
body: JSON.stringify({
ports,
}),
},
).then(res => res.json())
export const getSecretkey = () =>
fetchAbs(SECRET_KEY)
.then(res => res.json())
.then(json => json.secret_key)
export const getConfig = () => {
};
export const postConfig = (config, subConfigName) =>
fetchAbs(
subConfigName ? CONFIG + "/" + subConfigName : CONFIG,
{
method: 'POST',
body: JSON.stringify(config),
},
);
// Checks if the server's base config has been setup.
export const getServerSetup = () => fetchAbs(SETUP_CHECK)
.then(res => res.json())
export const startSynapse = () => fetchAbs(
START,
{
method: 'POST',
}
)
|