mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 07:38:35 +08:00
terseness
This commit is contained in:
+8
-2
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user