The test case output says “Root level logger middleware should be active”. But when I go to /json, the logger works properly and outputs the correct string (ex: “GET /json - ::ffff:127.0.0.1”). I’m confused as to what might be going wrong.
Here’s my server:
var express = require('express');
var app = express();
app.use((req, res, next) => {
console.log(req.method + ' ' + req.path + ' - ' + req.ip);
next();
});
app.use(express.static(__dirname+'/public'));
app.get('/', (req, res) => {
res.sendFile(__dirname + '/views/index.html');
});
/** 5) serve JSON on a specific route */
app.get('/json', (req, res) => {
const resObj = {
message: "Hello json"
};
if(process.env.MESSAGE_STYLE === 'uppercase') {
resObj.message = resObj.message.toUpperCase();
}
res.json(resObj);
});
module.exports = app;