terseness

This commit is contained in:
Riley Davis
2016-11-03 11:33:32 -06:00
parent 73be4cfe28
commit c2d4e1255b
2 changed files with 10 additions and 12 deletions
+8 -2
View File
@@ -1,11 +1,17 @@
const mongoose = require('../mongoose');
const uuid = require('uuid');
const Schema = mongoose.Schema;
const SettingSchema = new Schema({
id: {type: String, default: '1'},
moderation: {type: String, enum: ['pre', 'post'], default: 'pre'},
}, {timestamps: {createdAt: 'created_at', updatedAt: 'updated_at'}});
}, {
_id: false,
timestamps: {
createdAt: 'created_at',
updatedAt: 'updated_at'
}
});
SettingSchema.statics.getSettings = function () {
return this.findOne();
+2 -10
View File
@@ -4,19 +4,11 @@ const path = require('path');
const Setting = require(path.resolve(__dirname, 'models/setting'));
router.get('/settings', (req, res, next) => {
Setting.getSettings().then(settings => {
res.json(settings);
}).catch(error => {
next(error);
});
Setting.getSettings().then(res.json).catch(next);
});
router.put('/settings', (req, res, next) => {
Setting.updateSettings(req.body).then(updatedSettings => {
res.json(updatedSettings);
}).catch(error => {
next(error);
});
Setting.updateSettings(req.body).then(res.json).catch(next);
});
module.exports = router;