2022-10-05 00:12:50 -04:00
|
|
|
const config = require('config');
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2022-09-25 01:31:59 -04:00
|
|
|
const minecraft = require('../app/MinecraftServer');
|
|
|
|
|
2022-09-25 00:40:25 -04:00
|
|
|
exports.getIndex = function(req, res) {
|
2022-10-05 00:12:50 -04:00
|
|
|
// search for minecraft server directories
|
|
|
|
let rootDir = config.get('server_directory');
|
|
|
|
let serverDirs = fs.readdirSync(rootDir);
|
|
|
|
let servers = [];
|
|
|
|
for (let i = 0; i < serverDirs.length; i++) {
|
|
|
|
servers.push(new minecraft.Server(path.join(rootDir, serverDirs[i])));
|
|
|
|
}
|
|
|
|
|
|
|
|
// render view
|
2022-09-25 00:59:05 -04:00
|
|
|
res.render('index', {
|
2022-10-05 00:12:50 -04:00
|
|
|
servers: servers,
|
2022-09-25 00:59:05 -04:00
|
|
|
});
|
2022-09-25 00:40:25 -04:00
|
|
|
};
|