mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 14:43:00 +00:00
migrating repo to Bodyrep org
This commit is contained in:
21
routes/middleware/load_workout.js
Normal file
21
routes/middleware/load_workout.js
Normal file
@@ -0,0 +1,21 @@
|
||||
var workout = require('../../data/models/workout');
|
||||
|
||||
function loadworkout(req, res, next) {
|
||||
console.log('fetch id' + req.params.title );
|
||||
workout.findOne({title: req.params.title})
|
||||
.populate('elements')
|
||||
|
||||
.exec(function(err, workout) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (! workout) {
|
||||
return res.send('Not found', 404);
|
||||
}
|
||||
console.log('workout' + JSON.stringify(workout));
|
||||
req.workout = workout;
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = loadworkout;
|
||||
Reference in New Issue
Block a user