Not able to pass this level
Is my code missing something or the format is error or misplaced?
See the image attach for my codes for this level. You can refer to this link for my code boilerplate-express (2) - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
Challenge: Basic Node and Express - Implement a Root-Level Request Logger Middleware
Link to the challenge:
The repl link you posted doesnât work: " boilerplate-express-2.vlchung.repl.co unexpectedly closed the connection."
YeahâŚI know because my code is not working
Can you post a link to your code please? (Rather than your live project link).
I donât know if my code is misplaced / wrong format / missing something. Can you help me to check?
let express = require(âexpressâ);
let app = express();
console.log(âHello World!â);
app.use(function middleware(req, res, next) {
var str = req.method + " " + req.path + " - " + req.ip;
console.log(str);
next();
});
app.get(â/â, function(req, res) {
res.sendFile(__dirname + â/views/index.htmlâ);
});
// Normal usage
app.use(express.static(__dirname + â/publicâ));
// Assets at the /public route
app.use(â/publicâ, express.static(__dirname + â/publicâ));
process.env.MESSAGE_STYLE=âuppercaseâ;
app.get(â/jsonâ, function(req, res){
// Variable assignment as object
var response = {
âmessageâ: âHello jsonâ
};
if(process.env.MESSAGE_STYLE===âuppercaseâ){
//Override message attribute value based on condition
response.message = response.message.toUpperCase();
}
return res.json(response);
});
No, I mean a direct link to your repl code.
My link for example:
https://replit.com/@igorgetmeabrain/boilerplate-express#myApp.js
Youâve lost a line of code from the bottom of your myApp.js file:
module.exports = app;
Add that back in and your repl should run properly.
I added back the code that you mentioned and passed this level.
Thanks a lot! 
1 Like