Skip to content

Commit 0b243da

Browse files
committed
Implement response
1 parent 74eee7f commit 0b243da

4 files changed

Lines changed: 41 additions & 4 deletions

File tree

node_modules/.package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"dependencies": {
33
"express": "^5.1.0"
4-
}
4+
},
5+
"name": "module-decomposition",
6+
"version": "1.0.0",
7+
"description": "Exercises to practice and solidify your understanding of the Decomposition module of the Software Development Course.",
8+
"main": "script.js",
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"repository": {
13+
"type": "module",
14+
"url": "git+https://github.com/RihannaP/Module-Decomposition.git"
15+
},
16+
"keywords": [],
17+
"author": "",
18+
"license": "ISC",
19+
"bugs": {
20+
"url": "https://github.com/RihannaP/Module-Decomposition/issues"
21+
},
22+
"homepage": "https://github.com/RihannaP/Module-Decomposition#readme"
523
}

script.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@ app.post("/", usernameExtractor,(req, res) => {
2525

2626
let response = "";
2727

28+
if (username) {
29+
response += `You are authenticated as ${username}.`;
30+
} else {
31+
response += `You are not authenticated.`;
32+
}
2833

34+
const count = subjects.length;
35+
const subjectArr = subjects.join(", ");
36+
if (count === 0) {
37+
response += "You have requested information about 0 subject.";
38+
} else {
39+
const plural = count > 1 ? "subjects" : "subject";
40+
response += `You have requested information about ${count} ${plural}: ${subjectArr}.`;
41+
}
2942

3043
res.send(response);
3144
});

0 commit comments

Comments
 (0)