mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-23 05:19:37 +02:00
Added option to pin new apps/categories by default
This commit is contained in:
parent
43e110d378
commit
8b87ad92f1
5 changed files with 111 additions and 14 deletions
|
@ -2,12 +2,29 @@ const asyncWrapper = require('../middleware/asyncWrapper');
|
|||
const ErrorResponse = require('../utils/ErrorResponse');
|
||||
const Category = require('../models/Category');
|
||||
const Bookmark = require('../models/Bookmark');
|
||||
const Config = require('../models/Config');
|
||||
|
||||
// @desc Create new category
|
||||
// @route POST /api/categories
|
||||
// @access Public
|
||||
exports.createCategory = asyncWrapper(async (req, res, next) => {
|
||||
const category = await Category.create(req.body);
|
||||
// Get config from database
|
||||
const pinCategories = await Config.findOne({
|
||||
where: { key: 'pinCategoriesByDefault' }
|
||||
});
|
||||
|
||||
let category;
|
||||
|
||||
if (pinCategories) {
|
||||
if (parseInt(pinCategories.value)) {
|
||||
category = await Category.create({
|
||||
...req.body,
|
||||
isPinned: true
|
||||
})
|
||||
} else {
|
||||
category = await Category.create(req.body);
|
||||
}
|
||||
}
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue