pull/20/head
tycrek 3 years ago
parent 54d0708df5
commit 82736a236c
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -90,14 +90,14 @@ function startup() {
// Block unauthorized requests and attempt token sanitization // Block unauthorized requests and attempt token sanitization
app.post('/', (req, res, next) => { app.post('/', (req, res, next) => {
req.token = req.headers.authorization.replace(/[^\da-z]/gi, ''); req.token = req.headers.authorization.replace(/[^\da-z]/gi, '');
!verify(req, users) ? res.sendStatus(401) : next(); !verify(req, users) ? res.sendStatus(401) : next(); // skipcq: JS-0093
}); });
// Generate ID's to use for other functions // Generate ID's to use for other functions
app.post('/', (req, _res, next) => (req.randomId = generateId('random', 32, null, null), next())); app.post('/', (req, _res, next) => (req.randomId = generateId('random', 32, null, null), next()));
app.post('/', (req, _res, next) => (req.deleteId = generateId('random', 32, null, null), next())); app.post('/', (req, _res, next) => (req.deleteId = generateId('random', 32, null, null), next()));
// Upload file (local & S3) // Upload file (local & S3) // skipcq: JS-0093
s3enabled s3enabled
? app.post('/', (req, res, next) => uploadS3(req, res, (error) => ((error) && console.error(error), next()))) ? app.post('/', (req, res, next) => uploadS3(req, res, (error) => ((error) && console.error(error), next())))
: app.post('/', uploadLocal, ({ next }) => next()); : app.post('/', uploadLocal, ({ next }) => next());
@ -220,7 +220,7 @@ function startup() {
// Parse the resource ID // Parse the resource ID
req.ass = { resourceId: escape(req.params.resourceId).split('.')[0] }; req.ass = { resourceId: escape(req.params.resourceId).split('.')[0] };
// If the ID is invalid, return 404. Otherwise, continue normally // If the ID is invalid, return 404. Otherwise, continue normally // skipcq: JS-0093
(!req.ass.resourceId || !data[req.ass.resourceId]) ? res.sendStatus(404) : next(); (!req.ass.resourceId || !data[req.ass.resourceId]) ? res.sendStatus(404) : next();
}); });

@ -13,7 +13,7 @@ module.exports = () => {
Object.values(data).forEach(({ token, size }) => { Object.values(data).forEach(({ token, size }) => {
try { try {
totalSize += size; totalSize += size;
if (token === undefined) oldSize += size; if (token === undefined) oldSize += size; // skipcq: JS-0127
else { else {
if (!users[token].size) users[token].size = 0; if (!users[token].size) users[token].size = 0;
users[token].size += size; users[token].size += size;

Loading…
Cancel
Save