Skip to content

Instantly share code, notes, and snippets.

@jrgleason
Forked from daslicht/gist:3427267
Created August 22, 2012 16:38
Show Gist options
  • Save jrgleason/3427285 to your computer and use it in GitHub Desktop.
Save jrgleason/3427285 to your computer and use it in GitHub Desktop.
//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