-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapps.js
76 lines (70 loc) · 2.19 KB
/
apps.js
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
const express = require("express");
const router = express.Router();
const util = require("./sse/util");
router.post("/install/:id", (req, res) => {
console.info("call to /api/apps/install for app", req.params.id);
// send information that btc-pay is currently installing
util.sendSSE("install", {
id: "rtl",
mode: "on",
result: "running",
details: "",
});
setTimeout(() => {
installApp();
}, 5000);
res.status(200).send();
});
router.post("/uninstall/:id", (req, res) => {
console.info("call to /api/apps/uninstall for app", req.params.id);
// TODO: Create the same example as install but with uninstall
res.status(200).send();
});
router.get("/status_advanced/electrs", (req, res) => {
console.info("call to /api/apps/status_advanced/electrs");
res.status(200).send(
JSON.stringify({
version: "v0.10.2",
localIP: "192.168.0.1",
publicIP: "127.0.0.1",
portTCP: "50001",
portSSL: "50002",
// not a real onion address
TORaddress:
"gr7l4dtesftz3t48p2nhbpzwhs5fm2t4fgnavh9v0tdvp80z2jzg5xw1@rzqwnilfge21ma7gr9v40zf7btz4u8rmz7353ua4vtl77yb328vqfl6369az0nv8.onion",
initialSyncDone: true,
}),
);
});
const installApp = () => {
console.info("call to installApp");
// inform Frontend that app finished installing
util.sendSSE("install", {
id: "rtl",
mode: "on",
result: "win",
httpsForced: "0",
httpsSelfsigned: "1",
details: "OK",
});
util.sendSSE("installed_app_status", [
{ id: "lnbits", installed: false, status: "offline", error: "" },
{ id: "thunderhub", installed: false, status: "offline", error: "" },
{ id: "btcpayserver", installed: false, status: "offline", error: "" },
{ id: "mempool", installed: false, status: "offline", error: "" },
{ id: "btc-rpc-explorer", installed: false, status: "offline", error: "" },
{
id: "rtl",
installed: true,
status: "online",
address: "http://192.168.1.100:3000",
httpsForced: "0",
httpsSelfsigned: "1",
hiddenService: "4pt2ludsdsdns48dwnd2899rqf63pcdwdwdwh7dwaeukn1w.onion",
authMethod: "password_b",
details: {},
error: "",
},
]);
};
module.exports = router;