Skip to content
Snippets Groups Projects
Commit 362b7646 authored by Iain Bryson's avatar Iain Bryson
Browse files

Make zip routes work for multiple projects.

parent 3dda89d0
Branches
No related tags found
No related merge requests found
......@@ -21,29 +21,46 @@ export default ({ config, db }) => resource({
},
/** GET / - List all entities */
index({ params }, res) {
index(req, res) {
res.connection.setTimeout(10*60*1000);
req.socket.setKeepAlive(10*60*1000);
db.projects.find({}, (err, projects) => {
var allDetails = [];
logger.info(`Zipping all projects`);
console.dir(projects);
var jobs = projects.map( (project) => {
return (callback) => {
zipProject(db, project, (err, details) => {
allDetails.push(details);
callback(details);
callback(err, details);
})
}
});
async.series(jobs, (details) => {
logger.info(`Total zip jobs: ${jobs.length} ${allDetails}`);
async.series(jobs, (err, details) => {
logger.info(`Finished archiving all projects`);
console.dir(details);
res.json(details);
if (err) {
logger.error("error: ");
logger.error(err);
res.status(400).json({error: err});
} else {
res.status(200).json(details);
}
})
});
},
/** GET /:id - Return a given entity */
read({ project }, res) {
logger.info(`Starting archiving project ${project._id}`);
zipProject(db, project, (err, details) => {
res.json(details);
logger.info(`Finished archiving project ${project._id}`);
if (err) {
res.status(400).json({error: err});
} else {
res.status(200).json(details);
}
})
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment