Add addon configure route

This commit is contained in:
Johannes Zellner
2018-11-21 15:47:34 +01:00
parent e04b7b55b0
commit c1183a09a8
3 changed files with 49 additions and 0 deletions
+19
View File
@@ -3,6 +3,7 @@
exports = module.exports = {
getAll: getAll,
get: get,
configure: configure,
getLogs: getLogs,
getLogStream: getLogStream,
start: start,
@@ -35,6 +36,24 @@ function get(req, res, next) {
});
}
function configure(req, res, next) {
assert.strictEqual(typeof req.params.addon, 'string');
if (typeof req.body.memory !== 'number') return next(new HttpError(400, 'memory must be a number'));
const data = {
memory: req.body.memory,
memorySwap: req.body.memory * 2
};
addons.configureAddon(req.params.addon, data, function (error) {
if (error && error.reason === AddonsError.NOT_FOUND) return next(new HttpError(404, 'No such addon'));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(202, {}));
});
}
function getLogs(req, res, next) {
assert.strictEqual(typeof req.params.addon, 'string');