middleware and extra route

master
Matt Huntington 9 years ago
parent 39bb4d5885
commit 1ff2b714df

@ -3,7 +3,20 @@ var app = express(); //create application variable
var fakeArray = require('./models/fakearray.js');
var PORT = process.env.PORT || 3000;
console.log(fakeArray);
app.use(function(req, res, next){
console.log('middleware doin. stuff');
next();
});
app.use(function(req, res, next){
console.log('2nd middleware doin. stuff');
next();
});
app.use(function(req, res, next){
console.log('3rd middleware doin. stuff');
next();
});
app.get('/', function(request, response){
response.render('index.ejs', {
@ -11,6 +24,10 @@ app.get('/', function(request, response){
});
});
app.get('/foo', function(req, res){
res.send('works');
})
//params: port, callback to execute once listening has begun
app.listen(PORT, function () { //start app listening on port 3000
//once listening, execute this callback

Loading…
Cancel
Save