From 6d650d4f30e44fb6b4d587c5b5ac7be835414926 Mon Sep 17 00:00:00 2001 From: Hadidreem17 Date: Fri, 28 Nov 2025 19:27:19 +0100 Subject: [PATCH] Node.js Week 1 assignment --- .../hackyourtemperature/package.json | 18 +++++++++++++++++ .../hackyourtemperature/server.js | 17 ++++++++++++++++ package.json | 20 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 assignments/config-files/hackyourtemperature/package.json create mode 100644 assignments/config-files/hackyourtemperature/server.js create mode 100644 package.json diff --git a/assignments/config-files/hackyourtemperature/package.json b/assignments/config-files/hackyourtemperature/package.json new file mode 100644 index 000000000..9c2affe5b --- /dev/null +++ b/assignments/config-files/hackyourtemperature/package.json @@ -0,0 +1,18 @@ +{ + "name": "hackyourtemperature", + "version": "1.0.0", + "type": "module", + "description": "", + "main": "server.js", + "scripts": { + "start": "node server.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^5.1.0", + "express-handlebars": "^8.0.3", + "node-fetch": "^3.3.2" + } +} diff --git a/assignments/config-files/hackyourtemperature/server.js b/assignments/config-files/hackyourtemperature/server.js new file mode 100644 index 000000000..4873a4dac --- /dev/null +++ b/assignments/config-files/hackyourtemperature/server.js @@ -0,0 +1,17 @@ +import express from "express"; + +const app = express(); +app.use(express.json()); + +app.get("/", (req, res) => { + res.send("hello from backend to frontend!"); +}); + +app.post("/weather", (req, res) => { + const cityName = req.body.cityName; + res.send(`You sent: ${cityName}`); +}); + +app.listen(3000, () => { + console.log("Server running on http://localhost:3000"); +}); diff --git a/package.json b/package.json new file mode 100644 index 000000000..9803be463 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "node.js-cohort54", + "version": "1.0.0", + "description": "> If you are following the HackYourFuture curriculum we recommend you to start with module 1: [HTML/CSS/GIT](https://github.com/HackYourFuture/HTML-CSS). To get a complete overview of the HackYourFuture curriculum first, click [here](https://github.com/HackYourFuture/curriculum).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Hadidreem17/Node.js-Cohort54.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/Hadidreem17/Node.js-Cohort54/issues" + }, + "homepage": "https://github.com/Hadidreem17/Node.js-Cohort54#readme" +}