-
Notifications
You must be signed in to change notification settings - Fork 11
Khiro-W2-Node.js #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Khiro-W2-Node.js #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work,
You've made some good enough use case as required in the assignment requirements, with your clean structure you have covered key test scenarios.
One note though: you have placed your homework in the config-files lol...
Anyways, LGTM; keep it up. 🎉
import { API_KEY } from "./sources/keys.js"; | ||
const app = express(); | ||
app.use(express.json()); | ||
|
||
app.get("/", (req, res) => { | ||
res.send("Hello from the backend "); | ||
}); | ||
app.post("/weather", async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consistent line spacing improves readability.
node_modules/ | ||
.env | ||
.DS_Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
export const API_KEY = process.env.API_KEY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
if (response.status === 404) { | ||
return res.status(404).json({ Error: "Invalid city name" }); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two points:
- it's a good idea to check for the
response.ok
as it's not always a 404 same as not okay - you are returning, it's an early return, no need for an else statement.
"scripts": { | ||
"test": "jest", | ||
"start": "node server.js", | ||
"dev": "nodemon server.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it.
Completed the temperature app by fetching weather data from the openweathermap, accepting a city name via the POST method, and writing tests for the app.