Add route to get available languages

This commit is contained in:
Johannes Zellner
2020-11-18 00:10:06 +01:00
parent 2388fe5047
commit 784c8b2bd2
5 changed files with 39 additions and 8 deletions
+9
View File
@@ -20,6 +20,7 @@ exports = module.exports = {
prepareDashboardDomain,
renewCerts,
getServerIp,
getLanguages,
syncExternalLdap
};
@@ -313,3 +314,11 @@ function getServerIp(req, res, next) {
next(new HttpSuccess(200, { ip }));
});
}
function getLanguages(req, res, next) {
cloudron.getLanguages(function (error, languages) {
if (error) return next(new BoxError.toHttpError(error));
next(new HttpSuccess(200, { languages }));
});
}
+12
View File
@@ -558,5 +558,17 @@ describe('Cloudron API', function () {
});
});
});
describe('languages', function () {
it('succeeds', function (done) {
superagent.get(SERVER_URL + '/api/v1/cloudron/languages')
.end(function (error, result) {
expect(result.statusCode).to.equal(200);
expect(result.body.languages).to.be.an('array');
expect(result.body.languages.indexOf('en')).to.not.equal(-1);
done();
});
});
});
});
});