新增 高级创建服务器API

This commit is contained in:
Suwings 2020-10-24 20:18:08 +08:00
parent 6adc9ddd09
commit 4daf4fe859
2 changed files with 25 additions and 0 deletions

View File

@ -75,6 +75,10 @@ class MinecraftServer extends ServerProcess {
//关服命令
this.dataModel.stopCommand = args.stopCommand || "";
this.dataModel.dockerConfig = args.dockerConfig || this.dataModel.dockerConfig;
this.dataModel.mcpingConfig = args.mcpingConfig || this.dataModel.mcpingConfig;
this.propertiesLoad();
}

View File

@ -279,5 +279,26 @@ router.post("/execute/", function (req, res) {
}
});
// 创建服务器实例JSON | API
router.post("/advanced_create_server", function (req, res) {
// 仅仅准许管理员使用
if (!keyManager.isMaster(apiResponse.key(req))) {
apiResponse.forbidden(res);
return;
}
// 解析请求参数
try {
const params = req.body;
const config = JSON.parse(params.config);
// 创建
const result = serverModel.createServer(params.serverName, config);
// 返回状态码
result ? apiResponse.ok(res) : apiResponse.error(res);
} catch (err) {
apiResponse.error(res, err);
}
});
//模块导出
module.exports = router;