forked from mirror/MCSManager
新增 高级创建服务器API
This commit is contained in:
parent
6adc9ddd09
commit
4daf4fe859
@ -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();
|
||||
}
|
||||
|
||||
|
21
route/api.js
21
route/api.js
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user