mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 22:51:37 +00:00
added rudimentary admin pages, started testing validation code
This commit is contained in:
17
routes/middleware/load_exercise.js
Normal file
17
routes/middleware/load_exercise.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var exercise = require('../../data/models/exercise');
|
||||
|
||||
function loadexercise(req, res, next) {
|
||||
exercise.findOne({_id: req.params._id})
|
||||
.exec(function(err, exercise) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (! exercise) {
|
||||
return res.send('Not found', 404);
|
||||
}
|
||||
req.exercise = exercise;
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = loadexercise;
|
||||
@@ -11,12 +11,6 @@ function loadworkout(req, res, next) {
|
||||
if (! workout) {
|
||||
return res.send('Not found', 404);
|
||||
}
|
||||
console.log('workout' + JSON.stringify(workout));
|
||||
workout.elements.forEach(function(element, index, array) {
|
||||
// console.log("elementID" + element._id);
|
||||
// console.log("elementID" + JSON.stringify(element.splits));
|
||||
});
|
||||
|
||||
req.workout = workout;
|
||||
next();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user