Fix server-side linting erros

This commit is contained in:
Cassie Tarakajian 2020-03-03 18:52:39 -05:00
parent 1107f7352a
commit 9de8257464
3 changed files with 42 additions and 43 deletions

View file

@ -60,14 +60,14 @@ export function deleteObjectsFromS3(keyList, callback) {
}
export function deleteObjectFromS3(req, res) {
const { object_key, user_id } = req.params;
let objectKey;
if (user_id) {
objectKey = `${user_id}/${object_key}`
const { objectKey, userId } = req.params;
let fullObjectKey;
if (userId) {
fullObjectKey = `${userId}/${objectKey}`;
} else {
objectKey = object_key;
fullObjectKey = objectKey;
}
deleteObjectsFromS3([objectKey], () => {
deleteObjectsFromS3([fullObjectKey], () => {
res.json({ success: true });
});
}
@ -75,7 +75,7 @@ export function deleteObjectFromS3(req, res) {
export function signS3(req, res) {
const limit = process.env.UPLOAD_LIMIT || 250000000;
if (req.user.totalSize > limit) {
res.status(403).send({message: 'user has uploaded the maximum size of assets.'});
res.status(403).send({ message: 'user has uploaded the maximum size of assets.' });
return;
}
const fileExtension = getExtension(req.body.name);
@ -95,7 +95,7 @@ export function signS3(req, res) {
policy: p.policy,
signature: p.signature
};
return res.json(result);
res.json(result);
}
export function copyObjectInS3(req, res) {
@ -135,9 +135,7 @@ export function listObjectsInS3ForUser(userId) {
.on('end', () => {
resolve();
});
}).then(() => {
return getProjectsForUserId(userId);
}).then((projects) => {
}).then(() => getProjectsForUserId(userId)).then((projects) => {
const projectAssets = [];
let totalSize = 0;
assets.forEach((asset) => {
@ -167,7 +165,7 @@ export function listObjectsInS3ForUser(userId) {
});
projectAssets.push(foundAsset);
});
return Promise.resolve({ assets: projectAssets, totalSize});
return Promise.resolve({ assets: projectAssets, totalSize });
}).catch((err) => {
console.log('got an error');
console.log(err);

View file

@ -1,3 +1,4 @@
/* eslint-disable */
import mongoose from 'mongoose';
import User from '../models/user';

View file

@ -6,7 +6,7 @@ const router = new Router();
router.post('/S3/sign', isAuthenticated, AWSController.signS3);
router.post('/S3/copy', isAuthenticated, AWSController.copyObjectInS3);
router.delete('/S3/:user_id?/:object_key', isAuthenticated, AWSController.deleteObjectFromS3);
router.delete('/S3/:userId?/:objectKey', isAuthenticated, AWSController.deleteObjectFromS3);
router.get('/S3/objects', AWSController.listObjectsInS3ForUserRequestHandler);
export default router;