feat(writeapi): admin settings update route
parent
2ec838fc59
commit
a55b381791
@ -0,0 +1,16 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const meta = require('../../meta');
|
||||||
|
|
||||||
|
const helpers = require('../helpers');
|
||||||
|
|
||||||
|
const Admin = module.exports;
|
||||||
|
|
||||||
|
Admin.updateSetting = async (req, res) => {
|
||||||
|
if (!res.locals.privileges['admin:settings']) {
|
||||||
|
return helpers.formatApiResponse(403, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
await meta.configs.set(req.params.setting, req.body.value);
|
||||||
|
helpers.formatApiResponse(200, res);
|
||||||
|
};
|
@ -0,0 +1,16 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const router = require('express').Router();
|
||||||
|
const middleware = require('../../middleware');
|
||||||
|
const controllers = require('../../controllers');
|
||||||
|
const routeHelpers = require('../helpers');
|
||||||
|
|
||||||
|
const setupApiRoute = routeHelpers.setupApiRoute;
|
||||||
|
|
||||||
|
module.exports = function () {
|
||||||
|
const middlewares = [middleware.authenticate];
|
||||||
|
|
||||||
|
setupApiRoute(router, '/settings/:setting', middleware, [...middlewares, middleware.checkRequired.bind(null, ['value']), middleware.exposePrivilegeSet], 'put', controllers.write.admin.updateSetting);
|
||||||
|
|
||||||
|
return router;
|
||||||
|
};
|
Loading…
Reference in New Issue