2015-02-01 01:43:52 +00:00
|
|
|
module.exports = function (manager, mods) {
|
2015-01-21 02:18:45 +00:00
|
|
|
return {
|
|
|
|
index: function (req, res){
|
|
|
|
res.send(manager.getServers());
|
|
|
|
},
|
2014-04-06 22:58:17 +00:00
|
|
|
|
2015-01-21 02:18:45 +00:00
|
|
|
create: function (req, res) {
|
|
|
|
var server = manager.addServer(req.body);
|
2017-04-01 09:30:29 +00:00
|
|
|
res.send(server);
|
2015-01-21 02:18:45 +00:00
|
|
|
},
|
2014-04-04 08:37:43 +00:00
|
|
|
|
2015-01-21 02:18:45 +00:00
|
|
|
show: function (req, res){
|
|
|
|
var server = manager.getServer(req.params.server);
|
2014-09-12 23:51:31 +00:00
|
|
|
res.send(server);
|
2015-01-21 02:18:45 +00:00
|
|
|
},
|
2014-04-04 08:37:43 +00:00
|
|
|
|
2015-01-21 02:18:45 +00:00
|
|
|
update: function(req, res){
|
|
|
|
var server = manager.getServer(req.params.server);
|
|
|
|
server.update(req.body);
|
|
|
|
manager.save();
|
2017-04-01 09:30:29 +00:00
|
|
|
res.send(server);
|
2015-01-21 02:18:45 +00:00
|
|
|
},
|
2014-04-08 20:59:59 +00:00
|
|
|
|
2015-01-21 02:18:45 +00:00
|
|
|
destroy: function(req, res){
|
|
|
|
var server = manager.removeServer(req.params.server);
|
2014-06-04 22:17:18 +00:00
|
|
|
res.send(server);
|
2015-01-21 02:18:45 +00:00
|
|
|
},
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2015-01-21 02:18:45 +00:00
|
|
|
start: function (req, res){
|
|
|
|
var server = manager.getServer(req.params.server);
|
|
|
|
server.start();
|
|
|
|
res.send({status:"ok", pid: server.pid});
|
|
|
|
},
|
2014-04-06 22:58:17 +00:00
|
|
|
|
2015-01-21 02:18:45 +00:00
|
|
|
stop: function (req, res){
|
|
|
|
var server = manager.getServer(req.params.server);
|
|
|
|
server.stop(function () {
|
|
|
|
if (!server.pid) {
|
|
|
|
res.send({status: true, pid: server.pid});
|
|
|
|
} else {
|
|
|
|
res.send({status: false, pid: server.pid});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
2014-04-06 21:09:52 +00:00
|
|
|
};
|