-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (46 loc) · 1.5 KB
/
index.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
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const PORT = 4000;
const cors = require('cors');
const axios = require('axios');
const util = require('minecraft-server-util');
app.use(cors());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// Print Welcome Message
printWelcome();
// Basic route to display BeamMP server info
app.get('/beammp', (req, res) => {
let servers = [];
axios.get('https://beammp.com/servers-info').then(response => {
for (let i = 0; i < response.data.length; i++) {
if(response.data[i][i].owner == "perfectsquare150#8584"){
servers.push(response.data[i][i]);
}
}
res.send(servers);
});
});
// Basic route to display MC server info
app.get('/mc', (req, res) => {
util.status('mc.meetandgeek.ca')
.then((response) => {
res.send(response);
})
.catch((error) => {
console.log(error);
});
});
app.listen(PORT, function(){
console.log('Express server running on port:',PORT);
});
// Welcome message
function printWelcome() {
console.log("+-----------------------------------------+");
console.log("| Brain Games Backend Server |");
console.log("| v0.1 |");
console.log("| jslightham & contributors |");
console.log("| (https://github.com/jslightham) |");
console.log("+-----------------------------------------+");
}