Can't pass Implement a Root-Level Request Logger Middleware even though it's working

Tell us what’s happening:
It just says “Root level logger middleware should be active” even though it seems to be working on my end, I see everything printed to my Node console whenever I open localhost:3000 or localhost:3000/json in my browser. Here’s my code for reference:

const express = require(‘express’)
const app = express()
const path = require(‘path’)
require(‘dotenv’).config()

app.use((req, _res, next) => {
console.log(${req.method} ${req.path} - ${req.ip})
next()
})

app.get(’/’, (_req, res) => res.sendFile(path.join(__dirname, ‘/views/index.html’)))

app.use(’/public’, express.static(path.join(__dirname, ‘/public’)))

app.get(’/json’, (_req, res) => {
res.json({ message: process.env.MESSAGE_STYLE === ‘uppercase’ ? ‘HELLO JSON’ : ‘Hello json’ })
})

module.exports = app

Your project link(s)

solution: http://localhost:3000

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0

Challenge: Implement a Root-Level Request Logger Middleware

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.