Adjusting based on PR feedback, added public filter to settings object

This commit is contained in:
Wyatt Johnson
2016-12-06 11:55:15 -05:00
parent d2d4640eee
commit 5298efa89f
4 changed files with 42 additions and 17 deletions
+9
View File
@@ -1,5 +1,6 @@
const mongoose = require('../mongoose');
const Schema = mongoose.Schema;
const _ = require('lodash');
const cache = require('../cache');
/**
@@ -82,6 +83,14 @@ SettingService.update = (settings) => Setting.findOneAndUpdate(selector, {
.then(() => settings);
});
/**
* Filters the document to ensure that the resulting document is indeed ready
* for non authenticated users.
* @param {Object} settings the source settings object
* @return {Object} the filtered settings object
*/
SettingService.public = (settings) => _.pick(settings, ['moderation', 'infoBoxEnable', 'infoBoxContent']);
/**
* This is run once when the app starts to ensure settings are populated.
* @return {Promise} null initialize the global settings object