0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-03 23:32:58 +00:00

Move default brew to app.js

This commit is contained in:
G.Ambatte
2022-12-14 19:23:16 +13:00
parent 0a885c8581
commit f470a6185a
3 changed files with 30 additions and 19 deletions

View File

@@ -9,23 +9,7 @@ const yaml = require('js-yaml');
const asyncHandler = require('express-async-handler');
const { nanoid } = require('nanoid');
// Default brew properties in most cases
const DEFAULT_BREW = {
title : 'Untitled Brew',
description : '',
renderer : 'V3',
tags : [],
systems : [],
thumbnail : '',
published : false,
pageCount : 1,
theme : '5ePHB'
};
// Default brew properties for loading
const DEFAULT_BREW_LOAD = {
renderer : 'legacy',
published : true
};
const { DEFAULT_BREW, DEFAULT_BREW_LOAD } = require('./brewDefaults.js');
// const getTopBrews = (cb) => {
// HomebrewModel.find().sort({ views: -1 }).limit(5).exec(function(err, brews) {
@@ -89,7 +73,7 @@ const getBrew = (accessType, stubOnly = false)=>{
}
// Use _.assignWith instead of _.defaults - does this need to be replicated at all other uses of _.defaults???
_.assignWith(stub, DEFAULT_BREW_LOAD, DEFAULT_BREW, (objValue, srcValue)=>{
_.assignWith(stub, DEFAULT_BREW_LOAD, (objValue, srcValue)=>{
if(typeof objValue === 'boolean') return objValue;
return objValue || srcValue;
});