mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
API routes to edit and delete custom themes. Added ThemeEditor table
This commit is contained in:
parent
bd96f6ca50
commit
ad92de141b
5 changed files with 107 additions and 3 deletions
22
controllers/themes/deleteTheme.js
Normal file
22
controllers/themes/deleteTheme.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const asyncWrapper = require('../../middleware/asyncWrapper');
|
||||
const File = require('../../utils/File');
|
||||
|
||||
// @desc Delete theme
|
||||
// @route DELETE /api/themes/:name
|
||||
// @access Public
|
||||
const deleteTheme = asyncWrapper(async (req, res, next) => {
|
||||
const file = new File('data/themes.json');
|
||||
let content = JSON.parse(file.read());
|
||||
|
||||
content.themes = content.themes.filter((t) => t.name != req.params.name);
|
||||
file.write(content, true);
|
||||
|
||||
const userThemes = content.themes.filter((t) => t.isCustom);
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: userThemes,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = deleteTheme;
|
Loading…
Add table
Add a link
Reference in a new issue