From 1ff2b714dfa8aca250ea390042f71c9a28cb2775 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Tue, 23 Aug 2016 09:02:56 -0400 Subject: [PATCH] middleware and extra route --- server.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index d2ce11c..3eca22e 100644 --- a/server.js +++ b/server.js @@ -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