Tell us what’s happening:
Hi, the challenge keeps showing that ‘Root level logger middleware should be active’.
The platform that I use is repl.it.
I think, my code should not have any problems.
Your code so far
var express = require(‘express’);
var app = express();
app.use((req, res, next) => {
let log = req.method + ’ ’ + req.path + ’ - ’ + req.ip;
console.log(log);
next();
});
let static_dir = __dirname + ‘/public’;
app.use(express.static(static_dir));
app.get(’/’, function(req,res){
let file_path = __dirname + ‘/views/index.html’;
res.sendFile(file_path)
});
app.get(’/json’, function (req,res) {
const message = process.env.MESSAGE_STYLE === ‘uppercase’ ? ‘HELLO JSON’ : ‘Hello json’;
return res.json({message});
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36
.
Challenge: Implement a Root-Level Request Logger Middleware
Link to the challenge: