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

Commit 143a18d

Browse files
committed
Add new setting; Performance improvements
Small bug fixes
1 parent fe12be6 commit 143a18d

File tree

10 files changed

+25
-18
lines changed

10 files changed

+25
-18
lines changed

config/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
"immediateDeletion": {
9999
"type": "boolean"
100100
},
101+
"usePreferredColorScheme": {
102+
"type": "boolean"
103+
},
101104
"theme": {
102105
"type": "string",
103106
"enum": ["default", "dark"]

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ MAINTAINER Simon Reinisch <toports@gmx.de>
66
WORKDIR /app
77

88
# Upgrade
9-
RUN apt update && \
10-
apt upgrade -y
9+
RUN apt-get update && \
10+
apt-get upgrade -y
1111

1212
# Copy content into the container at /app
1313
COPY . /app

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"url": "git+https://github.com/ovanta/vue-cloudfront-api"
1313
},
1414
"scripts": {
15-
"dev": "nodemon ./src/app.js --ignore '/_storage'",
15+
"dev": "nodemon ./src/app.js --ignore '/_storage' --watch src",
1616
"debug": "node %NODE_DEBUG_OPTION% ./src/app.js",
1717
"build:docker": "docker build -f docker/Dockerfile . -t vue-cloudfront-rest-api",
1818
"update:geoip-lite": "cd node_modules/geoip-lite && npm run-script updatedb",

src/api/endpoints/auth/login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = async req => {
3232
if (lastLoginAttemptMs < blockedLoginDuration) {
3333
throw {code: 404, text: `Try again in ${readableDuration(blockedLoginDuration - lastLoginAttemptMs)}`};
3434
} else {
35-
user.loginAttempts = 0;
35+
user.set('loginAttempts', 0);
3636
}
3737
}
3838

src/api/endpoints/data/static.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const nodeModel = require('../../../models/node');
22
const fs = require('fs');
33

44
module.exports = async (req, res) => {
5-
const {_user, id} = req.query;
5+
const {_user, id} = req.body;
66

77
if (typeof id !== 'string') {
88
throw {code: 103, text: 'Invalid node id'};

src/api/endpoints/data/upload/upload.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = async req => {
5656
}
5757

5858
// Create and push new node
59-
const newNode = await new nodeModel({
59+
nodes.push(new nodeModel({
6060
owner: user.id,
6161
id: filename,
6262
parent: parent,
@@ -71,10 +71,8 @@ module.exports = async req => {
7171
console.warn(reason); // eslint-disable-line no-console
7272
fs.unlink(path, () => 0);
7373
return null;
74-
});
75-
76-
newNode && nodes.push(newNode);
74+
}));
7775
}
7876

79-
return nodes;
77+
return Promise.all(nodes);
8078
};

src/api/endpoints/user/logoutEverywhere.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ module.exports = async req => {
44
const {_user} = req.body;
55

66
// Clear apikeys
7-
_user.apikeys = [];
8-
_user.markModified('apikeys');
7+
_user.set('apikeys', []);
98

109
// Broadcast logout
1110
websocket.broadcast({

src/api/middleware/auth.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const userModel = require('../../models/user');
22

33
module.exports = (req, res, next) => {
4-
const {apikey} = req.body;
4+
const {apikey} = (req.body || req.query);
55

66
if (typeof apikey !== 'string' || !apikey) {
77
throw 'APIKey is invalid';
@@ -22,12 +22,19 @@ module.exports = (req, res, next) => {
2222

2323
// Remove expired apikeys
2424
const now = Date.now();
25-
user.apikeys = user.apikeys.filter(
25+
user.set('apikeys', user.apikeys.filter(
2626
({expiry}) => expiry > now
27-
);
27+
));
2828

2929
return user.save();
3030
}).then(user => {
31+
32+
// Merge query and body
33+
req.body = {
34+
...req.body,
35+
...req.query
36+
};
37+
3138
req.body._user = user;
3239
next();
3340
});

src/api/tools/authViaApiKey.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ module.exports = async apikey => {
2121

2222
// Remove expired apikeys
2323
const now = Date.now();
24-
user.apikeys = user.apikeys.filter(
24+
user.set('apikeys', user.apikeys.filter(
2525
({expiry}) => expiry > now
26-
);
26+
));
2727

2828
return user.save();
2929
});

src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const express = require('express');
22
const server = require('http').createServer();
3-
const fs = require('fs');
43
const cors = require('cors');
54
const path = require('path');
5+
const fs = require('fs');
66

77
// Resolve storage path and create global config variable
88
const config = require('../config/config');

0 commit comments

Comments
 (0)