Add settings for Spaces

This commit is contained in:
Girish Ramakrishnan
2018-08-02 19:09:54 -07:00
parent 2a49569805
commit d3f9647cd5
3 changed files with 58 additions and 2 deletions

View File

@@ -23,7 +23,10 @@ exports = module.exports = {
setAppstoreConfig: setAppstoreConfig,
getPlatformConfig: getPlatformConfig,
setPlatformConfig: setPlatformConfig
setPlatformConfig: setPlatformConfig,
setSpacesConfig: setSpacesConfig,
getSpacesConfig: getSpacesConfig
};
var assert = require('assert'),
@@ -200,6 +203,26 @@ function setPlatformConfig(req, res, next) {
});
}
function getSpacesConfig(req, res, next) {
settings.getSpacesConfig(function (error, config) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, config));
});
}
function setSpacesConfig(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
settings.setSpacesConfig(req.body, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return next(new HttpError(400, error.message));
if (error && error.reason === SettingsError.EXTERNAL_ERROR) return next(new HttpError(402, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, {}));
});
}
function getAppstoreConfig(req, res, next) {
settings.getAppstoreConfig(function (error, result) {
if (error) return next(new HttpError(500, error));