2020-12-10 17:01:55 +01:00
|
|
|
var apiUtils = require("../util");
|
|
|
|
|
|
|
|
var runtimeAPI;
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
init: function(_runtimeAPI) {
|
|
|
|
runtimeAPI = _runtimeAPI;
|
|
|
|
},
|
|
|
|
getAll: function(req,res) {
|
|
|
|
var opts = {
|
|
|
|
user: req.user,
|
|
|
|
req: apiUtils.getRequestLogObject(req)
|
|
|
|
}
|
|
|
|
if (req.get("accept") == "application/json") {
|
|
|
|
runtimeAPI.plugins.getPluginList(opts).then(function(list) {
|
|
|
|
res.json(list);
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
opts.lang = apiUtils.determineLangFromHeaders(req.acceptsLanguages());
|
2021-05-11 17:42:00 +02:00
|
|
|
if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
|
|
|
|
opts.lang = "en-US";
|
2021-01-26 14:35:40 +01:00
|
|
|
}
|
2020-12-10 17:01:55 +01:00
|
|
|
runtimeAPI.plugins.getPluginConfigs(opts).then(function(configs) {
|
|
|
|
res.send(configs);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getCatalogs: function(req,res) {
|
|
|
|
var opts = {
|
|
|
|
user: req.user,
|
|
|
|
lang: req.query.lng,
|
|
|
|
req: apiUtils.getRequestLogObject(req)
|
|
|
|
}
|
2021-05-11 17:42:00 +02:00
|
|
|
if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
|
|
|
|
opts.lang = "en-US";
|
2021-01-26 14:35:40 +01:00
|
|
|
}
|
2020-12-10 17:01:55 +01:00
|
|
|
runtimeAPI.plugins.getPluginCatalogs(opts).then(function(result) {
|
|
|
|
res.json(result);
|
|
|
|
}).catch(function(err) {
|
|
|
|
console.log(err.stack);
|
|
|
|
apiUtils.rejectHandler(req,res,err);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
};
|