Skip to content
This repository was archived by the owner on Dec 15, 2019. It is now read-only.

Commit 724589c

Browse files
committed
Drop stats; Setup bare settings scheme
1 parent 9205511 commit 724589c

File tree

7 files changed

+52
-42
lines changed

7 files changed

+52
-42
lines changed

config/config.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"port": 8080,
2323
"storagePath": "./_storage",
2424
"uploadSizeLimitPerFile": 5000000000,
25-
"totalStorageLimitPerUser": 10000000000,
25+
"totalStorageLimitPerUser": 1000000000,
2626
"mediaStreamChunckSize": 4096000
2727
},
2828
"mongodb": {
@@ -69,14 +69,19 @@
6969
"dirname": "^(.){1,100}$",
7070
"hexcolor": "^#([\\dA-Fa-f]{6})$",
7171
"schemes": {
72-
"stats": {
73-
"introBoxes": {
74-
"type": "array",
75-
"minItems": 0,
76-
"maxItems": 3,
77-
"items": {
78-
"type": "string"
72+
"settings": {
73+
"static": {
74+
"introBoxes": {
75+
"type": "array",
76+
"minItems": 0,
77+
"maxItems": 3,
78+
"items": {
79+
"type": "string"
80+
}
7981
}
82+
},
83+
"user": {
84+
"siPrefix": "boolean"
8085
}
8186
}
8287
}

package-lock.json

Lines changed: 24 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "vue-cloudfront-api",
33
"version": "0.0.1",
4+
"private": true,
45
"description": "Official RESTful api for vue-cloudfront",
56
"author": "Simon Reinisch",
67
"license": "MIT",

src/api/api.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ const upload = require('./endpoints/data/upload/upload');
5353
const del = require('./endpoints/data/delete');
5454

5555
// === Events endpoints
56-
const getStats = require('./endpoints/stats/getStats');
57-
const updateStats = require('./endpoints/stats/updateStats');
56+
const settings = require('./endpoints/settings/settings');
57+
const updateSettings = require('./endpoints/settings/updateSettings');
5858

5959
api.post('/addMark', json, mapHandler(addMark));
6060
api.post('/changeColor', json, mapHandler(changeColor));
@@ -85,7 +85,7 @@ api.post('/updateCredentials', json, mapHandler(updateCredentials));
8585
api.post('/deleteAccount', json, mapHandler(deleteAccount));
8686
api.post('/status', json, mapHandler(status));
8787

88-
api.post('/updateStats', json, mapHandler(updateStats));
89-
api.post('/getStats', json, mapHandler(getStats));
88+
api.post('/updateSettings', json, mapHandler(updateSettings));
89+
api.post('/settings', json, mapHandler(settings));
9090

9191
module.exports = api;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const authViaApiKey = require('../../tools/authViaApiKey');
22

3-
module.exports = async ({body: {apikey}}) => (await authViaApiKey(apikey)).stats;
3+
module.exports = async ({body: {apikey}}) => (await authViaApiKey(apikey)).settings;
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
const authViaApiKey = require('../../tools/authViaApiKey');
22
const Validator = new (require('jsonschema').Validator);
3-
const statsScheme = _config.validation.schemes.stats;
3+
const settingsScheme = _config.validation.schemes.settings;
4+
const userModel = require('../../../models/user');
45

56
module.exports = async req => {
6-
const {stats, apikey} = req.body;
7+
const {settings, apikey} = req.body;
78

89
// Find user
910
const user = await authViaApiKey(apikey);
10-
const validationResult = Validator.validate(stats, statsScheme);
11+
const validationResult = Validator.validate(settings, settingsScheme);
1112

1213
// Check if validation has failed
1314
if (validationResult.errors.length) {
1415
throw 'Invalid stats scheme';
1516
}
1617

1718
// Apply, mark as modified and save
18-
user.stats = stats;
19-
user.markModified('stats');
20-
return user.save().then(() => null);
19+
return userModel.updateOne(
20+
{id: user.id},
21+
{$set: {settings}}
22+
).exec().then(() => null);
2123
};

src/models/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = mongoose.model('User', {
2222
expiry: Number
2323
}],
2424

25-
stats: {
25+
settings: {
2626
type: Object,
2727
required: true,
2828
default: {}

0 commit comments

Comments
 (0)