arma-server-web-admin/routes/mods.js

59 lines
1.3 KiB
JavaScript
Raw Normal View History

module.exports = function (modsManager) {
return {
index: function(req, res){
res.send(modsManager.mods);
},
create: function(req, res){
modsManager.download(req.body.name, function (err, mods) {
if (err || !mods) {
res.send(500, err);
} else {
res.send(mods);
}
});
},
show: function(req, res){
modsManager.traverse(req.params.mod, function (err, files) {
if (err || !files) {
console.error(err.stack || err);
res.send(500, err);
} else {
res.json(files);
}
2014-04-04 08:37:43 +00:00
});
},
update: function(req, res){
modsManager.download(req.params.mod, function (err, mods) {
if (err || !mods) {
res.send(500, err);
} else {
res.send(mods);
}
});
},
2014-04-04 08:37:43 +00:00
destroy: function(req, res){
res.send('destroy mod ' + req.params.mod);
},
2015-02-01 04:01:50 +00:00
2015-05-29 23:30:53 +00:00
refresh: function(req, res){
modsManager.updateMods();
res.send(200, {});
},
2015-02-01 04:01:50 +00:00
search: function(req, res){
var query = req.body.query || "";
modsManager.search(query, function (err, mods) {
if (err || !mods) {
res.send(500, err);
} else {
res.send(mods);
}
});
}
};
};