fix lingering linting errors
This commit is contained in:
parent
5de876e202
commit
c30aba8e78
3 changed files with 21 additions and 22 deletions
|
@ -118,11 +118,9 @@ export function listObjectsInS3ForUser(req, res) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let assets = [];
|
let assets = [];
|
||||||
const list = client.listObjects(params)
|
client.listObjects(params)
|
||||||
.on('data', (data) => {
|
.on('data', (data) => {
|
||||||
assets = assets.concat(data["Contents"].map((object) => {
|
assets = assets.concat(data.Contents.map(object => ({ key: object.Key, size: object.Size })));
|
||||||
return { key: object["Key"], size: object["Size"] };
|
|
||||||
}));
|
|
||||||
})
|
})
|
||||||
.on('end', () => {
|
.on('end', () => {
|
||||||
const projectAssets = [];
|
const projectAssets = [];
|
||||||
|
@ -131,7 +129,7 @@ export function listObjectsInS3ForUser(req, res) {
|
||||||
project.files.forEach((file) => {
|
project.files.forEach((file) => {
|
||||||
if (!file.url) return;
|
if (!file.url) return;
|
||||||
|
|
||||||
const foundAsset = assets.find((asset) => file.url.includes(asset.key));
|
const foundAsset = assets.find(asset => file.url.includes(asset.key));
|
||||||
if (!foundAsset) return;
|
if (!foundAsset) return;
|
||||||
projectAssets.push({
|
projectAssets.push({
|
||||||
name: file.name,
|
name: file.name,
|
||||||
|
@ -143,7 +141,7 @@ export function listObjectsInS3ForUser(req, res) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
res.json({assets: projectAssets});
|
res.json({ assets: projectAssets });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -139,33 +139,35 @@ export function getProjectsForUserId(userId) {
|
||||||
export function getProjectAsset(req, res) {
|
export function getProjectAsset(req, res) {
|
||||||
Project.findById(req.params.project_id)
|
Project.findById(req.params.project_id)
|
||||||
.populate('user', 'username')
|
.populate('user', 'username')
|
||||||
.exec((err, project) => {
|
.exec((err, project) => { // eslint-disable-line
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(404).send({ message: 'Project with that id does not exist' });
|
return res.status(404).send({ message: 'Project with that id does not exist' });
|
||||||
}
|
}
|
||||||
|
|
||||||
var assetURL = null;
|
let assetURL = null;
|
||||||
var seekPath = req.params[0]; // req.params.asset_path;
|
const seekPath = req.params[0]; // req.params.asset_path;
|
||||||
var seekPathSplit = seekPath.split('/');
|
const seekPathSplit = seekPath.split('/');
|
||||||
var seekFilename = seekPathSplit[seekPathSplit.length-1];
|
const seekFilename = seekPathSplit[seekPathSplit.length - 1];
|
||||||
project.files.forEach((file) => {
|
project.files.forEach((file) => {
|
||||||
if(file.name === seekFilename) {
|
if (file.name === seekFilename) {
|
||||||
assetURL = file.url;
|
assetURL = file.url;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!assetURL) {
|
if (!assetURL) {
|
||||||
return res.status(404).send({ message: 'Asset does not exist' });
|
return res.status(404).send({ message: 'Asset does not exist' });
|
||||||
} else {
|
|
||||||
request({ method: 'GET', url: assetURL, encoding: null }, (err, response, body) => {
|
|
||||||
res.send(body);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
request({ method: 'GET', url: assetURL, encoding: null }, (innerErr, response, body) => {
|
||||||
|
if (innerErr) {
|
||||||
|
return res.status(404).send({ message: 'Asset does not exist' });
|
||||||
|
}
|
||||||
|
return res.send(body);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProjectsForUserName(username) {
|
export function getProjectsForUserName(username) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProjects(req, res) {
|
export function getProjects(req, res) {
|
||||||
|
@ -199,7 +201,6 @@ export function getProjectsForUser(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bundleExternalLibs(project, zip, callback) {
|
function bundleExternalLibs(project, zip, callback) {
|
||||||
const rootFile = project.files.find(file => file.name === 'root');
|
|
||||||
const indexHtml = project.files.find(file => file.name === 'index.html');
|
const indexHtml = project.files.find(file => file.name === 'index.html');
|
||||||
let numScriptsResolved = 0;
|
let numScriptsResolved = 0;
|
||||||
let numScriptTags = 0;
|
let numScriptTags = 0;
|
||||||
|
|
|
@ -17,7 +17,7 @@ router.route('/signup').get((req, res) => {
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
}
|
}
|
||||||
res.send(renderIndex());
|
return res.send(renderIndex());
|
||||||
});
|
});
|
||||||
|
|
||||||
router.route('/projects/:project_id').get((req, res) => {
|
router.route('/projects/:project_id').get((req, res) => {
|
||||||
|
@ -29,7 +29,7 @@ router.route('/:username/sketches/:project_id').get((req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.route('/:username/sketches/:project_id/*').get((req, res) => {
|
router.route('/:username/sketches/:project_id/*').get((req, res) => {
|
||||||
getProjectAsset(req,res);
|
getProjectAsset(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
// router.route('/full/:project_id').get((req, res) => {
|
// router.route('/full/:project_id').get((req, res) => {
|
||||||
|
@ -40,7 +40,7 @@ router.route('/login').get((req, res) => {
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
}
|
}
|
||||||
res.send(renderIndex());
|
return res.send(renderIndex());
|
||||||
});
|
});
|
||||||
|
|
||||||
router.route('/reset-password').get((req, res) => {
|
router.route('/reset-password').get((req, res) => {
|
||||||
|
|
Loading…
Reference in a new issue