mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-26 07:01:38 +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;
|
||||
Reference in New Issue
Block a user