Skip to content

Commit 3affed0

Browse files
authored
Update serverAPI.js
1 parent 42e6a4d commit 3affed0

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

src/utils/serverAPI.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,33 @@ const config = require('../../rpe.config.json');
33
const { server } = config;
44
let { port } = config;
55

6-
export function devices() { return `${server}:${port}/devices`; }
7-
export function attributes() { return `${server}:${port}/attributes`; }
8-
export function project() { return `${server}:${port}/project`; }
9-
export function projectClose() { return `${project()}/close`; }
10-
export function projectOpen() { return `${project()}/open`; }
11-
export function projectSave() { return `${project()}/create`; }
6+
export function devices() {
7+
return `${server}:${port}/devices`;
8+
}
9+
10+
export function attributes() {
11+
return `${server}:${port}/attributes`;
12+
}
13+
14+
export function project() {
15+
return `${server}:${port}/project`;
16+
}
17+
18+
export function projectClose() {
19+
return `${project()}/close`;
20+
}
21+
22+
export function projectOpen() {
23+
return `${project()}/open`;
24+
}
25+
26+
export function projectSave() {
27+
return `${project()}/create`;
28+
}
1229

1330
export function setPort(p, fetchDevices) {
1431
if (p !== undefined) {
1532
port = p;
16-
// eslint-disable-next-line no-use-before-define
1733
GET(devices(), fetchDevices);
1834
}
1935
}
@@ -80,7 +96,7 @@ export function PATCH(url, data, callback) {
8096
if (response.ok) {
8197
if (callback) callback();
8298
} else {
83-
// todo handle error
99+
// TODO: handle error
84100
}
85101
});
86102
}
@@ -92,3 +108,9 @@ export function GET(url, callback) {
92108
if (callback) callback(data);
93109
});
94110
}
111+
112+
// function to call the shutdown API
113+
export function shutdown(callback) {
114+
const shutdownUrl = 'http://localhost:5000/shutdown';
115+
POST(shutdownUrl, null, callback);
116+
}

0 commit comments

Comments
 (0)