-
-
Save jrgleason/3427285 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//in main app: | |
require('./routes').init(app); | |
//index.js in folder /routes | |
module.exports = | |
{ | |
init:function(app){ | |
require('./index')(app); | |
} | |
} | |
//create.js in the /routes folder | |
module.exports = function(app){ | |
var create = function(req,res,next){ | |
//Do in here | |
return next() | |
} | |
var addToMongo = function(req, res, next){ | |
//Next route | |
return next() | |
} | |
var middleware = [create, addToMongo] | |
app.get('/create', middleware, | |
function(req, res) | |
{ | |
res.render('create', { title: 'Create' }) | |
} | |
); | |
app.get('/other',middleware,function(req, res){ | |
res.render('other',{}) | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment