Root level logger middleware should be active*
I’ve been at this for over an hour and I’m still not able to pass my code this is what i have
let express = require(‘express’);
let app = express();
app.use((req, _res, next) => {
console.log(${req.method} ${req.path} '-' ${req.ip}
);
next();
});
require(‘dotenv’).config();
app.use(/public
, express.static(${__dirname}/public
));
app.get(“/”, (req, res)=>{
res.sendFile(${__dirname}/views/index.html
);
});
app.get(/json
, (req, res)=> {
let greeting = ‘Hello json’;
if(process.env.MESSAGE_STYLE === 'uppercase') {
greeting = greeting.toUpperCase();
}
res.json({message: greeting});
});
module.exports = app;
solution: http://localhost:3000
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Challenge: Basic Node and Express - Implement a Root-Level Request Logger Middleware
Link to the challenge: