translation: asyncify
This commit is contained in:
@@ -248,24 +248,22 @@ function setSysinfoConfig(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function getLanguage(req, res, next) {
|
||||
settings.getLanguage(function (error, language) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
async function getLanguage(req, res, next) {
|
||||
const [error, language] = await safe(settings.getLanguage());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { language }));
|
||||
});
|
||||
next(new HttpSuccess(200, { language }));
|
||||
}
|
||||
|
||||
function setLanguage(req, res, next) {
|
||||
async function setLanguage(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (!req.body.language || typeof req.body.language !== 'string') return next(new HttpError(400, 'language is required'));
|
||||
|
||||
settings.setLanguage(req.body.language, function (error) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
const [error] = await safe(settings.setLanguage(req.body.language));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
});
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
function get(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user