1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-23 05:19:37 +02:00

Changed config api. Split config controllers into separate files. Split bookmarks controllers into separate files

This commit is contained in:
Paweł Malak 2021-10-22 14:00:38 +02:00
parent 76e50624e7
commit cfb471e578
23 changed files with 579 additions and 602 deletions

View file

@ -4,15 +4,13 @@ const Category = require('../models/Category');
const Bookmark = require('../models/Bookmark');
const Config = require('../models/Config');
const { Sequelize } = require('sequelize');
const loadConfig = require('../utils/loadConfig');
// @desc Create new category
// @route POST /api/categories
// @access Public
exports.createCategory = asyncWrapper(async (req, res, next) => {
// Get config from database
const pinCategories = await Config.findOne({
where: { key: 'pinCategoriesByDefault' },
});
const { pinCategoriesByDefault: pinCategories } = await loadConfig();
let category;
@ -37,12 +35,8 @@ exports.createCategory = asyncWrapper(async (req, res, next) => {
// @route GET /api/categories
// @access Public
exports.getCategories = asyncWrapper(async (req, res, next) => {
// Get config from database
const useOrdering = await Config.findOne({
where: { key: 'useOrdering' },
});
const { useOrdering: orderType } = await loadConfig();
const orderType = useOrdering ? useOrdering.value : 'createdAt';
let categories;
if (orderType == 'name') {