fix merge conflict
This commit is contained in:
commit
63b47319d4
2 changed files with 33 additions and 0 deletions
|
@ -136,6 +136,34 @@ export function getProjectsForUserId(userId) {
|
|||
});
|
||||
}
|
||||
|
||||
export function getProjectAsset(req, res) {
|
||||
Project.findById(req.params.project_id)
|
||||
.populate('user', 'username')
|
||||
.exec((err, project) => {
|
||||
if (err) {
|
||||
return res.status(404).send({ message: 'Project with that id does not exist' });
|
||||
}
|
||||
|
||||
var assetURL = null;
|
||||
var seekPath = req.params[0]; // req.params.asset_path;
|
||||
var seekPathSplit = seekPath.split('/');
|
||||
var seekFilename = seekPathSplit[seekPathSplit.length-1];
|
||||
project.files.forEach((file) => {
|
||||
if(file.name === seekFilename) {
|
||||
assetURL = file.url;
|
||||
}
|
||||
});
|
||||
|
||||
if(!assetURL) {
|
||||
return res.status(404).send({ message: 'Asset does not exist' });
|
||||
} else {
|
||||
request({ method: 'GET', url: assetURL, encoding: null }, (err, response, body) => {
|
||||
res.send(body);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getProjectsForUserName(username) {
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { Router } from 'express';
|
|||
import { renderIndex } from '../views/index';
|
||||
import { get404Sketch } from '../views/404Page';
|
||||
import { userExists } from '../controllers/user.controller';
|
||||
import { getProjectAsset } from '../controllers/project.controller';
|
||||
|
||||
const router = new Router();
|
||||
|
||||
|
@ -24,6 +25,10 @@ router.route('/:username/sketches/:project_id').get((req, res) => {
|
|||
res.send(renderIndex());
|
||||
});
|
||||
|
||||
router.route('/:username/sketches/:project_id/*').get((req, res) => {
|
||||
getProjectAsset(req,res);
|
||||
});
|
||||
|
||||
// router.route('/full/:project_id').get((req, res) => {
|
||||
// res.send(renderIndex());
|
||||
// });
|
||||
|
|
Loading…
Reference in a new issue