mirror of
https://github.com/strapi/strapi.git
synced 2025-07-24 17:40:18 +00:00

git-subtree-dir: packages/strapi-plugin-settings-manager git-subtree-mainline: 80aa83d8460c95366547e143c74bf79ea6ae69f8 git-subtree-split: cd241c14c6a6239bca279e7accd709ba58e87cc8
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const _ = require('lodash');
|
|
const fs = require('fs');
|
|
|
|
/**
|
|
* A set of functions called "actions" for `SettingsManager`
|
|
*/
|
|
|
|
module.exports = {
|
|
|
|
getGeneralSettings: async (ctx) => {
|
|
// Pick values from `strapi.config`
|
|
const settings = _.pick(strapi.config, [
|
|
'name',
|
|
'version',
|
|
'description'
|
|
]);
|
|
|
|
ctx.body = settings;
|
|
},
|
|
|
|
updateSettings: async (ctx) => {
|
|
const data = ctx.request.body;
|
|
|
|
try {
|
|
const settingsUpdated = await strapi.plugins['settings-manager'].services.settingsservice.configurationsManager(strapi, data);
|
|
ctx.body = settingsUpdated.values;
|
|
} catch (err) {
|
|
console.log('err', err);
|
|
ctx.status = err && err.status || 400;
|
|
return ctx.body = {
|
|
message: err.msg || 'An error occurred during settings update'
|
|
};
|
|
}
|
|
},
|
|
|
|
file: async (ctx) => {
|
|
try {
|
|
const file = fs.readFileSync(path.resolve(__dirname, '..', 'public', 'build', ctx.params.file));
|
|
ctx.body = file;
|
|
} catch (err) {
|
|
ctx.body = ctx.notFound();
|
|
}
|
|
}
|
|
};
|