Just starting to explore Express and its middleware functions.
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.send('id: ' + req.params.id + ' and name: ' + req.params.name);
});
var things = require('./things/things.js');
//both index.js and things.js should be in same directory
app.use('/things', things);
//Simple request time logger
app.use('/',function(req, res, next){
console.log("A new request received at " + Date.now());
//This function call is crucial for further processing of the current request
//and routing it to the next middleware function.
next();
});
app.listen(3000);
I'm experimenting with middleware functions and trying to output a message on localhost:3000, but nothing shows up in my console. Any idea what I might be overlooking?