mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
Changed config api. Split config controllers into separate files. Split bookmarks controllers into separate files
This commit is contained in:
parent
76e50624e7
commit
cfb471e578
23 changed files with 579 additions and 602 deletions
24
controllers/config/updateConfig.js
Normal file
24
controllers/config/updateConfig.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const asyncWrapper = require('../../middleware/asyncWrapper');
|
||||
const loadConfig = require('../../utils/loadConfig');
|
||||
const { writeFile } = require('fs/promises');
|
||||
|
||||
// @desc Update config
|
||||
// @route PUT /api/config/
|
||||
// @access Public
|
||||
const updateConfig = asyncWrapper(async (req, res, next) => {
|
||||
const existingConfig = await loadConfig();
|
||||
|
||||
const newConfig = {
|
||||
...existingConfig,
|
||||
...req.body,
|
||||
};
|
||||
|
||||
await writeFile('data/config.json', JSON.stringify(newConfig));
|
||||
|
||||
res.status(200).send({
|
||||
success: true,
|
||||
data: newConfig,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = updateConfig;
|
Loading…
Add table
Add a link
Reference in a new issue