This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathapi.ts
64 lines (55 loc) · 1.9 KB
/
api.ts
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
/*--------------------------------------------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*-------------------------------------------------------------------------------------------*/
function postHTTP(url, postData) {
const request = new Request(url, {
method: "POST",
headers: new Headers({
"Content-Type": "application/json",
}),
body: JSON.stringify(postData),
});
return window.fetch(request);
}
export function getBoardPackages(update) {
return window.fetch(`/api/boardpackages?update=${update}`).then((response) => response.json());
}
export function installBoard(packageName, arch, version) {
return postHTTP("/api/installboard", {
packageName,
arch,
version,
}).then((response) => response.json());
}
export function uninstallBoard(boardName, packagePath) {
return postHTTP("/api/uninstallboard", {
boardName,
packagePath,
}).then((response) => response.json());
}
export function openLink(link) {
return postHTTP("/api/openlink", {
link,
}).then((response) => response.json());
}
export function getLibraries(update) {
return window.fetch(`/api/libraries?update=${update}`).then((response) => response.json());
}
export function installLibrary(libraryName, version) {
return postHTTP("/api/installlibrary", {
libraryName,
version,
}).then((response) => response.json());
}
export function uninstallLibrary(libraryName, libraryPath) {
return postHTTP("/api/uninstalllibrary", {
libraryName,
libraryPath,
}).then((response) => response.json());
}
export function addLibPath(path) {
return postHTTP("/api/addlibpath", {
path,
}).then((response) => response.json());
}