We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93a05ea commit 18cf904Copy full SHA for 18cf904
1 file changed
middleware-exercises/custom-middleware/server.js
@@ -72,10 +72,14 @@ app.use(parseJSONArrayBody);
72
* The handler only needs to build the response — all validation is done.
73
*/
74
app.post("/", (req, res) => {
75
+ if (!req.username) {
76
+ return res
77
+ .status(401)
78
+ .send(`You're not authenticated. Please, provide a username`);
79
+ }
80
+
81
// Authenticate if a username is provided
- const authLine = req.username
- ? `You're authenticated as ${req.username}`
- : `You're not authenticated!`;
82
+ const authLine = `You're authenticated as ${req.username}`;
83
84
// build subject based on count
85
const count = req.body.length;
0 commit comments