-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
70 lines (63 loc) · 1.41 KB
/
index.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
65
66
67
68
69
70
import * as dotenv from "dotenv"
import express from "express"
import RconWrapper from "./rcon-wrapper"
dotenv.config();
const app = express();
const port = 3003;
const rcon = new RconWrapper('localhost', 25575, 'password');
app.get("/", (req, res) => {
return res.status(200).json({
sucess: true,
})
});
app.get('/connect', (req, res) => {
rcon.connect().then(() => {
return res.status(200).json({
success: true,
message: "rcon connected"
})
}).catch(err => {
return res.status(500).json({
success: false,
message: err.message
})
})
});
app.get('/end', (req, res) => {
rcon.end().then(() => {
return res.status(200).json({
success: true,
message: "rcon disconnected"
})
}).catch(err => {
return res.status(500).json({
success: false,
message: err.message
})
})
});
app.get('/connectionstate', (req, res) => {
rcon.isConnected().then(rs => {
return res.status(200).json({
success: true,
state: rs
})
})
})
app.get('/whitelist', (req, res) => {
rcon.send("whitelist list").then(rs => {
return res.status(200).json({
success: true,
message: rs
})
}).catch(err => {
return res.status(500).json({
success: false,
message: err.message
})
})
});
// start and listen on the Express server
app.listen(port, () => {
console.log(`Express is listening on localhost:${port}`);
});