Timeout error -Basic Node and Express - Chain Middleware to Create a Time Server

I have a timeout error trying to pass this challenge here is my code so far in app.js:


var express = require('express');
var app = express();

app.use(function(req, res, next) {
console.log(`${req.method} ${req.path} - ${req.ip}`);
next();
})


app.get('/', function (req, res){
  res.send('Hello Express')
});



app.get('/hi', function (req, res){
  var absolutePath = __dirname + '/views/index.html'
  res.sendFile(absolutePath);
});

app.use(express.static(__dirname + '/public'));

process.env.MESSAGE_STYLE='uppercase';

app.get('/json', function (req,res){
  let msg = "Hello json";
  if (process.env.MESSAGE_STYLE==='uppercase') {
    msg = msg.toUpperCase();
  }
  res.json({"message": msg})  
});

// --> 7)  Mount the Logger middleware here
app.get('/now', function (req, res, next){
  req.time= new Date().toString()
}, function (req, res){
  res.send({time: req.time})
})

this is the link im trying to serve:

https://happy-scorpion.glitch.me/now

middle-ware need to execute the next() function if all is fine to pass control to the next matching route, otherwise they need to block it with a response or an exception

Ok, What is wrong with the below? I am getting the time @ the url and no errors in my logs

app.get('/now', function (req, res, next){
  req.time= new Date().toString()
  next()
}, function (req, res){
  res.send({time: req.time})
})

nothing is wrong, take a close look at the link you are submitting

I submitted both these links to the challenge, below each link are the returned results:

https://happy-scorpion.glitch.me/now
//Not Found
https://happy-scorpion.glitch.me/
//the returned time is not between +- 20 secs from now

I am thinking I have to convert a time somewhere…

your second link passes for me no problem, clearly the first one doesn’t pass because it is not pointing to your root route.