mcst/routes/home.js

20 lines
541 B
JavaScript
Raw Permalink Normal View History

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) {
// 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
res.render('index', {
servers: servers,
});
2022-09-25 00:40:25 -04:00
};