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

View file

@ -1,3 +1,4 @@
/* eslint-disable */
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import User from '../models/user'; 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/sign', isAuthenticated, AWSController.signS3);
router.post('/S3/copy', isAuthenticated, AWSController.copyObjectInS3); 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); router.get('/S3/objects', AWSController.listObjectsInS3ForUserRequestHandler);
export default router; export default router;