From 6b1cacf2d8082a252d1d706de12162f1f9f1f542 Mon Sep 17 00:00:00 2001 From: Samira Date: Mon, 17 Feb 2025 20:36:44 +0100 Subject: [PATCH 01/16] Added week1 assignment --- assignments/hackyourtemperature/package.json | 19 +++++++++++++++++++ assignments/hackyourtemperature/server.js | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 assignments/hackyourtemperature/package.json create mode 100644 assignments/hackyourtemperature/server.js diff --git a/assignments/hackyourtemperature/package.json b/assignments/hackyourtemperature/package.json new file mode 100644 index 000000000..6381552b6 --- /dev/null +++ b/assignments/hackyourtemperature/package.json @@ -0,0 +1,19 @@ +{ + "name": "hackyourtemperature", + "version": "1.0.0", + "main": "server.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "express": "^4.21.2", + "express-handlebars": "^8.0.1", + "node-fetch": "^3.3.2" + } +} diff --git a/assignments/hackyourtemperature/server.js b/assignments/hackyourtemperature/server.js new file mode 100644 index 000000000..118138496 --- /dev/null +++ b/assignments/hackyourtemperature/server.js @@ -0,0 +1,18 @@ +import express from 'express'; + +const app = express(); +const PORT = 3000; +app.use(express.json()); + +app.get('/', (req, res) => { + res.send('hello from backend to frontend'); +}); + +app.post('/weather' , (req, res) => { + const { cityName } = req.body + res.json({ message : `weather data received for ${cityName}`}); +}); + +app.listen(PORT , () => { + console.log(`Server is runnig on port ${PORT}`); +}); \ No newline at end of file From 904aa8294d19e375d40ac1de23b54d6266422802 Mon Sep 17 00:00:00 2001 From: Samira Date: Mon, 24 Feb 2025 11:45:09 +0100 Subject: [PATCH 02/16] Samira-w2-node.js --- assignments/hackyourtemperature/.gitignore.js | 0 assignments/hackyourtemperature/app.js | 38 +++++++++++++++++++ assignments/hackyourtemperature/package.json | 13 +++++-- assignments/hackyourtemperature/server.js | 13 +------ .../hackyourtemperature/sources/keys.js | 6 +++ .../hackyourtemperature/tests/app.test.js | 33 ++++++++++++++++ 6 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 assignments/hackyourtemperature/.gitignore.js create mode 100644 assignments/hackyourtemperature/app.js create mode 100644 assignments/hackyourtemperature/sources/keys.js create mode 100644 assignments/hackyourtemperature/tests/app.test.js diff --git a/assignments/hackyourtemperature/.gitignore.js b/assignments/hackyourtemperature/.gitignore.js new file mode 100644 index 000000000..e69de29bb diff --git a/assignments/hackyourtemperature/app.js b/assignments/hackyourtemperature/app.js new file mode 100644 index 000000000..e7cdefd0c --- /dev/null +++ b/assignments/hackyourtemperature/app.js @@ -0,0 +1,38 @@ +const express = require('express'); +const keys = require('./sources/keys.js'); +const fetch = require('node-fetch'); + +const app = express(); + +app.use(express.json()); + +app.get('/', async (req, res) => { + res.send("Hello from backend to frontend") +}); + +// Post route to fetch weather data +app.post('/weather', async (req, res) => { + const { cityName } = req.body; + + if (!cityName) { + return res.status(400).json({ message: "City name is required" }); + } + try { + const response = await fetch( + `https://api.openweathermap.org/data/2.5/weather?q=${cityName}&appid=${keys.API_KEY}&units=metric` + ); + const data = await response.json(); + + if (data.cod !== 200) { + return res.status(404).json({ message: "City is not found" }); + } + res.json({ + cityName : data.name, + temprature : data.main.temp + }); + + } catch (error) { + res.status(500).json({ message: "Server error" }); + } +}); +module.exports = app; \ No newline at end of file diff --git a/assignments/hackyourtemperature/package.json b/assignments/hackyourtemperature/package.json index 6381552b6..695980833 100644 --- a/assignments/hackyourtemperature/package.json +++ b/assignments/hackyourtemperature/package.json @@ -2,9 +2,8 @@ "name": "hackyourtemperature", "version": "1.0.0", "main": "server.js", - "type": "module", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "jest", "start": "node server.js" }, "keywords": [], @@ -14,6 +13,14 @@ "dependencies": { "express": "^4.21.2", "express-handlebars": "^8.0.1", - "node-fetch": "^3.3.2" + "node-fetch": "^2.7.0" + }, + "devDependencies": { + "@babel/core": "^7.26.9", + "@babel/preset-env": "^7.26.9", + "babel-jest": "^29.7.0", + "jest": "^29.7.0", + "supertest": "^7.0.0", + "ts-jest": "^29.2.6" } } diff --git a/assignments/hackyourtemperature/server.js b/assignments/hackyourtemperature/server.js index 118138496..ef74c9677 100644 --- a/assignments/hackyourtemperature/server.js +++ b/assignments/hackyourtemperature/server.js @@ -1,17 +1,6 @@ -import express from 'express'; +const app = require('./app.js'); -const app = express(); const PORT = 3000; -app.use(express.json()); - -app.get('/', (req, res) => { - res.send('hello from backend to frontend'); -}); - -app.post('/weather' , (req, res) => { - const { cityName } = req.body - res.json({ message : `weather data received for ${cityName}`}); -}); app.listen(PORT , () => { console.log(`Server is runnig on port ${PORT}`); diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js new file mode 100644 index 000000000..ed4b6c647 --- /dev/null +++ b/assignments/hackyourtemperature/sources/keys.js @@ -0,0 +1,6 @@ + +const keys = { BASE_URL: "https://api.openweathermap.org/data/2.5", // Base URL for openWeatherMap API + API_KEY: "62faffe5fe398983e589d80625a41622"// API key for authentication +}; + +module.exports = keys; \ No newline at end of file diff --git a/assignments/hackyourtemperature/tests/app.test.js b/assignments/hackyourtemperature/tests/app.test.js new file mode 100644 index 000000000..5288d11a5 --- /dev/null +++ b/assignments/hackyourtemperature/tests/app.test.js @@ -0,0 +1,33 @@ +const request = require("supertest"); +const app = require("../app.js"); + +describe("POST /weather" , () => { + it("should return weather data for a valid city", async () => { + const response = await request(app) + .post('/weather') + .send({ cityName: "London" }); + + expect(response.status).toBe(200); + expect(response.body).toHaveProperty("cityName"); + expect(response.body).toHaveProperty("temprature"); + }); + + it("should return an error for an invalid city", async () => { + const response = await request(app) + .post('/weather') + .send({ cityName: "InvalidCity" }); + + expect(response.status).toBe(404); + expect(response.body.message).toContain("City"); + }); + + it("should return an error for an empty city", async () => { + const response = await request(app) + .post('/weather') + .send({ cityName: "" }); + + expect(response.status).toBe(400); + expect(response.body).toHaveProperty("message", "City name is required"); + }); +}); + From d02eb86dd5a52701a1d0946b929c766a73938609 Mon Sep 17 00:00:00 2001 From: Samira Date: Mon, 24 Feb 2025 18:14:10 +0100 Subject: [PATCH 03/16] Samira Node.js week2 --- assignments/hackyourtemperature/app.js | 9 +++++---- assignments/hackyourtemperature/package.json | 3 ++- assignments/hackyourtemperature/server.js | 2 +- assignments/hackyourtemperature/sources/keys.js | 6 ++---- assignments/hackyourtemperature/tests/app.test.js | 5 ++--- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/assignments/hackyourtemperature/app.js b/assignments/hackyourtemperature/app.js index e7cdefd0c..260ab35ff 100644 --- a/assignments/hackyourtemperature/app.js +++ b/assignments/hackyourtemperature/app.js @@ -1,6 +1,7 @@ -const express = require('express'); -const keys = require('./sources/keys.js'); -const fetch = require('node-fetch'); +import express from 'express'; +import fetch from 'node-fetch'; +import keys from './sources/keys.js'; + const app = express(); @@ -35,4 +36,4 @@ app.post('/weather', async (req, res) => { res.status(500).json({ message: "Server error" }); } }); -module.exports = app; \ No newline at end of file +export default app; \ No newline at end of file diff --git a/assignments/hackyourtemperature/package.json b/assignments/hackyourtemperature/package.json index 695980833..3bc7c3036 100644 --- a/assignments/hackyourtemperature/package.json +++ b/assignments/hackyourtemperature/package.json @@ -2,12 +2,13 @@ "name": "hackyourtemperature", "version": "1.0.0", "main": "server.js", + "type": "module", "scripts": { "test": "jest", "start": "node server.js" }, "keywords": [], - "author": "", + "author": "ahmadi.samira6761@gmail.com", "license": "ISC", "description": "", "dependencies": { diff --git a/assignments/hackyourtemperature/server.js b/assignments/hackyourtemperature/server.js index ef74c9677..8e81868d1 100644 --- a/assignments/hackyourtemperature/server.js +++ b/assignments/hackyourtemperature/server.js @@ -1,4 +1,4 @@ -const app = require('./app.js'); +import app from './app.js'; const PORT = 3000; diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index ed4b6c647..700e91d28 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -1,6 +1,4 @@ -const keys = { BASE_URL: "https://api.openweathermap.org/data/2.5", // Base URL for openWeatherMap API - API_KEY: "62faffe5fe398983e589d80625a41622"// API key for authentication +export default { BASE_URL: "https://api.openweathermap.org/data/2.5", + API_KEY: "62faffe5fe398983e589d80625a41622" }; - -module.exports = keys; \ No newline at end of file diff --git a/assignments/hackyourtemperature/tests/app.test.js b/assignments/hackyourtemperature/tests/app.test.js index 5288d11a5..79e29de26 100644 --- a/assignments/hackyourtemperature/tests/app.test.js +++ b/assignments/hackyourtemperature/tests/app.test.js @@ -1,6 +1,5 @@ -const request = require("supertest"); -const app = require("../app.js"); - +import request from "supertest"; +import app from "../app.js"; describe("POST /weather" , () => { it("should return weather data for a valid city", async () => { const response = await request(app) From bace6fdd232160d408a16c43848c2eaa85de4a41 Mon Sep 17 00:00:00 2001 From: Samira Date: Mon, 24 Feb 2025 18:31:43 +0100 Subject: [PATCH 04/16] Samira.w2-node --- assignments/hackyourtemperature/app.js | 12 +++++++++--- assignments/hackyourtemperature/server.js | 1 + assignments/hackyourtemperature/sources/keys.js | 4 ++-- assignments/hackyourtemperature/tests/app.test.js | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/assignments/hackyourtemperature/app.js b/assignments/hackyourtemperature/app.js index 260ab35ff..70b51aa06 100644 --- a/assignments/hackyourtemperature/app.js +++ b/assignments/hackyourtemperature/app.js @@ -1,24 +1,28 @@ +// Import necessary modules import express from 'express'; import fetch from 'node-fetch'; import keys from './sources/keys.js'; - +// Initialize Express app const app = express(); +// Middleware to parse JSON request bodies app.use(express.json()); +// Define a simple GET route app.get('/', async (req, res) => { res.send("Hello from backend to frontend") }); // Post route to fetch weather data app.post('/weather', async (req, res) => { - const { cityName } = req.body; + const { cityName } = req.body; // Extract city name from request body if (!cityName) { - return res.status(400).json({ message: "City name is required" }); + return res.status(400).json({ message: "City name is required" }); // Validate the request } try { + // Fetch weather data from OpenWeatherMap API using provided city name and API key const response = await fetch( `https://api.openweathermap.org/data/2.5/weather?q=${cityName}&appid=${keys.API_KEY}&units=metric` ); @@ -27,6 +31,8 @@ app.post('/weather', async (req, res) => { if (data.cod !== 200) { return res.status(404).json({ message: "City is not found" }); } + + // return fetched weather data res.json({ cityName : data.name, temprature : data.main.temp diff --git a/assignments/hackyourtemperature/server.js b/assignments/hackyourtemperature/server.js index 8e81868d1..d7e32d2d7 100644 --- a/assignments/hackyourtemperature/server.js +++ b/assignments/hackyourtemperature/server.js @@ -2,6 +2,7 @@ import app from './app.js'; const PORT = 3000; +// Start the server on the specified port app.listen(PORT , () => { console.log(`Server is runnig on port ${PORT}`); }); \ No newline at end of file diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index 700e91d28..4b0ccb4bb 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -1,4 +1,4 @@ -export default { BASE_URL: "https://api.openweathermap.org/data/2.5", - API_KEY: "62faffe5fe398983e589d80625a41622" +export default { BASE_URL: "https://api.openweathermap.org/data/2.5", // Base URL for openWeatherMap API + API_KEY: "62faffe5fe398983e589d80625a41622"// API key for authentication }; diff --git a/assignments/hackyourtemperature/tests/app.test.js b/assignments/hackyourtemperature/tests/app.test.js index 79e29de26..b746be844 100644 --- a/assignments/hackyourtemperature/tests/app.test.js +++ b/assignments/hackyourtemperature/tests/app.test.js @@ -1,5 +1,8 @@ +// Import required modules for testing import request from "supertest"; import app from "../app.js"; + +// Define test suite for POST /weather route describe("POST /weather" , () => { it("should return weather data for a valid city", async () => { const response = await request(app) From 7d1c88f69a71d0a4b4fbb3cba5ceb8126e6c2613 Mon Sep 17 00:00:00 2001 From: Samira Date: Mon, 24 Feb 2025 19:03:42 +0100 Subject: [PATCH 05/16] Samira-w2-node --- assignments/hackyourtemperature/.gitignore.js | 1 + assignments/hackyourtemperature/package.json | 1 + assignments/hackyourtemperature/sources/keys.js | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/assignments/hackyourtemperature/.gitignore.js b/assignments/hackyourtemperature/.gitignore.js index e69de29bb..2eea525d8 100644 --- a/assignments/hackyourtemperature/.gitignore.js +++ b/assignments/hackyourtemperature/.gitignore.js @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/assignments/hackyourtemperature/package.json b/assignments/hackyourtemperature/package.json index 3bc7c3036..c17cef95b 100644 --- a/assignments/hackyourtemperature/package.json +++ b/assignments/hackyourtemperature/package.json @@ -12,6 +12,7 @@ "license": "ISC", "description": "", "dependencies": { + "dotenv": "^16.4.7", "express": "^4.21.2", "express-handlebars": "^8.0.1", "node-fetch": "^2.7.0" diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index 4b0ccb4bb..bac401ae7 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -1,4 +1,6 @@ +import dotenv from "dotenv"; +dotenv.config(); export default { BASE_URL: "https://api.openweathermap.org/data/2.5", // Base URL for openWeatherMap API - API_KEY: "62faffe5fe398983e589d80625a41622"// API key for authentication +API_KEY: process.env.API_KEY, }; From 840fe437907489541f6f5d952ee5e36192feea66 Mon Sep 17 00:00:00 2001 From: Samira Date: Mon, 24 Feb 2025 19:49:15 +0100 Subject: [PATCH 06/16] Samira-node-w2 --- assignments/hackyourtemperature/sources/keys.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index bac401ae7..b6039435f 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -1,6 +1,7 @@ import dotenv from "dotenv"; dotenv.config(); -export default { BASE_URL: "https://api.openweathermap.org/data/2.5", // Base URL for openWeatherMap API -API_KEY: process.env.API_KEY, +export default { + BASE_URL: process.env.BASE_URL, + API_KEY: process.env.API_KEY, }; From 1b1a006303b2f2f57b97ad1035b60ca1e14c9492 Mon Sep 17 00:00:00 2001 From: Samira Date: Tue, 4 Mar 2025 11:47:34 +0100 Subject: [PATCH 07/16] Samira updated assignments --- assignments/hackyourtemperature2/.env | 2 + assignments/hackyourtemperature2/.gitignore | 0 assignments/hackyourtemperature2/app.js | 45 +++++++++++++++++++ assignments/hackyourtemperature2/app.test.js | 35 +++++++++++++++ .../config-files/babel.config.cjs | 13 ++++++ .../config-files/jest.config.js | 8 ++++ assignments/hackyourtemperature2/package.json | 32 +++++++++++++ assignments/hackyourtemperature2/server.js | 8 ++++ .../hackyourtemperature2/sources/keys.js | 7 +++ 9 files changed, 150 insertions(+) create mode 100644 assignments/hackyourtemperature2/.env create mode 100644 assignments/hackyourtemperature2/.gitignore create mode 100644 assignments/hackyourtemperature2/app.js create mode 100644 assignments/hackyourtemperature2/app.test.js create mode 100644 assignments/hackyourtemperature2/config-files/babel.config.cjs create mode 100644 assignments/hackyourtemperature2/config-files/jest.config.js create mode 100644 assignments/hackyourtemperature2/package.json create mode 100644 assignments/hackyourtemperature2/server.js create mode 100644 assignments/hackyourtemperature2/sources/keys.js diff --git a/assignments/hackyourtemperature2/.env b/assignments/hackyourtemperature2/.env new file mode 100644 index 000000000..64556074b --- /dev/null +++ b/assignments/hackyourtemperature2/.env @@ -0,0 +1,2 @@ +BASE_URL=https://api.openweathermap.org/data/2.5 + API_KEY=62faffe5fe398983e589d80625a41622 \ No newline at end of file diff --git a/assignments/hackyourtemperature2/.gitignore b/assignments/hackyourtemperature2/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/assignments/hackyourtemperature2/app.js b/assignments/hackyourtemperature2/app.js new file mode 100644 index 000000000..70b51aa06 --- /dev/null +++ b/assignments/hackyourtemperature2/app.js @@ -0,0 +1,45 @@ +// Import necessary modules +import express from 'express'; +import fetch from 'node-fetch'; +import keys from './sources/keys.js'; + +// Initialize Express app +const app = express(); + +// Middleware to parse JSON request bodies +app.use(express.json()); + +// Define a simple GET route +app.get('/', async (req, res) => { + res.send("Hello from backend to frontend") +}); + +// Post route to fetch weather data +app.post('/weather', async (req, res) => { + const { cityName } = req.body; // Extract city name from request body + + if (!cityName) { + return res.status(400).json({ message: "City name is required" }); // Validate the request + } + try { + // Fetch weather data from OpenWeatherMap API using provided city name and API key + const response = await fetch( + `https://api.openweathermap.org/data/2.5/weather?q=${cityName}&appid=${keys.API_KEY}&units=metric` + ); + const data = await response.json(); + + if (data.cod !== 200) { + return res.status(404).json({ message: "City is not found" }); + } + + // return fetched weather data + res.json({ + cityName : data.name, + temprature : data.main.temp + }); + + } catch (error) { + res.status(500).json({ message: "Server error" }); + } +}); +export default app; \ No newline at end of file diff --git a/assignments/hackyourtemperature2/app.test.js b/assignments/hackyourtemperature2/app.test.js new file mode 100644 index 000000000..8f8dca7df --- /dev/null +++ b/assignments/hackyourtemperature2/app.test.js @@ -0,0 +1,35 @@ +// Import required modules for testing +import request from "supertest"; +import app from "./app.js"; + +// Define test suite for POST /weather route +describe("POST /weather" , () => { + it("should return weather data for a valid city", async () => { + const response = await request(app) + .post('/weather') + .send({ cityName: "London" }); + + expect(response.status).toBe(200); + expect(response.body).toHaveProperty("cityName"); + expect(response.body).toHaveProperty("temprature"); + }); + + it("should return an error for an invalid city", async () => { + const response = await request(app) + .post('/weather') + .send({ cityName: "InvalidCity" }); + + expect(response.status).toBe(404); + expect(response.body.message).toContain("City"); + }); + + it("should return an error for an empty city", async () => { + const response = await request(app) + .post('/weather') + .send({ cityName: "" }); + + expect(response.status).toBe(400); + expect(response.body).toHaveProperty("message", "City name is required"); + }); +}); + diff --git a/assignments/hackyourtemperature2/config-files/babel.config.cjs b/assignments/hackyourtemperature2/config-files/babel.config.cjs new file mode 100644 index 000000000..fbb629af6 --- /dev/null +++ b/assignments/hackyourtemperature2/config-files/babel.config.cjs @@ -0,0 +1,13 @@ +module.exports = { + presets: [ + [ + // This is a configuration, here we are telling babel what configuration to use + "@babel/preset-env", + { + targets: { + node: "current", + }, + }, + ], + ], +}; diff --git a/assignments/hackyourtemperature2/config-files/jest.config.js b/assignments/hackyourtemperature2/config-files/jest.config.js new file mode 100644 index 000000000..d77f65019 --- /dev/null +++ b/assignments/hackyourtemperature2/config-files/jest.config.js @@ -0,0 +1,8 @@ +export default { + // Tells jest that any file that has 2 .'s in it and ends with either js or jsx should be run through the babel-jest transformer + transform: { + "^.+\\.jsx?$": "babel-jest", + }, + // By default our `node_modules` folder is ignored by jest, this tells jest to transform those as well + transformIgnorePatterns: [], +}; diff --git a/assignments/hackyourtemperature2/package.json b/assignments/hackyourtemperature2/package.json new file mode 100644 index 000000000..4fb15f373 --- /dev/null +++ b/assignments/hackyourtemperature2/package.json @@ -0,0 +1,32 @@ +{ + "name": "hackyourtemperature", + "version": "1.0.0", + "main": "server.js", + "scripts": { + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", + "start": "node server.js" + }, + "keywords": [], + "type": "module", + "author": "ahmadi.samira6761@gmail.com", + "license": "ISC", + "dependencies": { + "dotenv": "^16.4.7", + "express": "^4.21.2", + "express-handlebars": "^8.0.1", + "node-fetch": "^2.7.0" + }, + "devDependencies": { + "@babel/core": "^7.26.9", + "@babel/preset-env": "^7.26.9", + "babel-jest": "^29.7.0", + "cross-env": "^7.0.3", + "jest": "^29.7.0", + "supertest": "^7.0.0", + "ts-jest": "^29.2.6" + }, + "directories": { + "test": "tests" + }, + "description": "" +} diff --git a/assignments/hackyourtemperature2/server.js b/assignments/hackyourtemperature2/server.js new file mode 100644 index 000000000..d7e32d2d7 --- /dev/null +++ b/assignments/hackyourtemperature2/server.js @@ -0,0 +1,8 @@ +import app from './app.js'; + +const PORT = 3000; + +// Start the server on the specified port +app.listen(PORT , () => { + console.log(`Server is runnig on port ${PORT}`); +}); \ No newline at end of file diff --git a/assignments/hackyourtemperature2/sources/keys.js b/assignments/hackyourtemperature2/sources/keys.js new file mode 100644 index 000000000..e5aa7611c --- /dev/null +++ b/assignments/hackyourtemperature2/sources/keys.js @@ -0,0 +1,7 @@ +import dotenv from "dotenv"; +dotenv.config(); + +export default { + BASE_URL:process.env.BASE_URL, + API_KEY:process.env.API_KEY, +}; From ecfc264bbe33d31ffb370bd07635b0a8537537d5 Mon Sep 17 00:00:00 2001 From: Samira Date: Wed, 5 Mar 2025 09:29:32 +0100 Subject: [PATCH 08/16] Samira updated assignments --- assignments/hackyourtemperature2/app.js | 18 +++++++++++------- assignments/hackyourtemperature2/app.test.js | 9 +++++---- assignments/hackyourtemperature2/server.js | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/assignments/hackyourtemperature2/app.js b/assignments/hackyourtemperature2/app.js index 70b51aa06..ed71b234b 100644 --- a/assignments/hackyourtemperature2/app.js +++ b/assignments/hackyourtemperature2/app.js @@ -16,10 +16,12 @@ app.get('/', async (req, res) => { // Post route to fetch weather data app.post('/weather', async (req, res) => { - const { cityName } = req.body; // Extract city name from request body - + // Extract city name from request body + const { cityName } = req.body; + + // Validate the request if (!cityName) { - return res.status(400).json({ message: "City name is required" }); // Validate the request + return res.status(400).json({ weatherText: "City name is required" }); } try { // Fetch weather data from OpenWeatherMap API using provided city name and API key @@ -28,18 +30,20 @@ app.post('/weather', async (req, res) => { ); const data = await response.json(); + if (data.cod !== 200) { - return res.status(404).json({ message: "City is not found" }); + return res.status(404).json({ weatherText: "City is not found" }); } // return fetched weather data res.json({ - cityName : data.name, - temprature : data.main.temp + temperature: data.main.temp, + weatherText: `The temperature in ${data.name} is ${data.main.temp}°C` + }); } catch (error) { - res.status(500).json({ message: "Server error" }); + res.status(500).json({ weatherText: "Server error" }); } }); export default app; \ No newline at end of file diff --git a/assignments/hackyourtemperature2/app.test.js b/assignments/hackyourtemperature2/app.test.js index 8f8dca7df..a0a06400c 100644 --- a/assignments/hackyourtemperature2/app.test.js +++ b/assignments/hackyourtemperature2/app.test.js @@ -10,8 +10,9 @@ describe("POST /weather" , () => { .send({ cityName: "London" }); expect(response.status).toBe(200); - expect(response.body).toHaveProperty("cityName"); - expect(response.body).toHaveProperty("temprature"); + expect(response.body).toHaveProperty("temperature"); + expect(response.body.temperature).toBeGreaterThan(-50); + expect(response.body.temperature).toBeLessThan(60); }); it("should return an error for an invalid city", async () => { @@ -20,7 +21,7 @@ describe("POST /weather" , () => { .send({ cityName: "InvalidCity" }); expect(response.status).toBe(404); - expect(response.body.message).toContain("City"); + expect(response.body).toHaveProperty("weatherText", "City is not found"); }); it("should return an error for an empty city", async () => { @@ -29,7 +30,7 @@ describe("POST /weather" , () => { .send({ cityName: "" }); expect(response.status).toBe(400); - expect(response.body).toHaveProperty("message", "City name is required"); + expect(response.body).toHaveProperty("weatherText", "City name is required"); }); }); diff --git a/assignments/hackyourtemperature2/server.js b/assignments/hackyourtemperature2/server.js index d7e32d2d7..eeef154bf 100644 --- a/assignments/hackyourtemperature2/server.js +++ b/assignments/hackyourtemperature2/server.js @@ -3,6 +3,6 @@ import app from './app.js'; const PORT = 3000; // Start the server on the specified port -app.listen(PORT , () => { +app.listen(PORT, () => { console.log(`Server is runnig on port ${PORT}`); }); \ No newline at end of file From 922f5088b182956fcd66f9ad00a918a07327f8bb Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 19:21:51 +0100 Subject: [PATCH 09/16] Added new update --- assignments/hackyourtemperature/.env | 2 ++ assignments/hackyourtemperature/.gitignore | 0 assignments/hackyourtemperature/.gitignore.js | 1 - assignments/hackyourtemperature/app.js | 18 +++++++++++------- .../{tests => }/app.test.js | 11 ++++++----- .../hackyourtemperature/babel.config.cjs | 13 +++++++++++++ assignments/hackyourtemperature/jest.config.js | 8 ++++++++ assignments/hackyourtemperature/package.json | 10 +++++++--- assignments/hackyourtemperature/server.js | 2 +- .../hackyourtemperature/sources/keys.js | 4 ++-- 10 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 assignments/hackyourtemperature/.env create mode 100644 assignments/hackyourtemperature/.gitignore delete mode 100644 assignments/hackyourtemperature/.gitignore.js rename assignments/hackyourtemperature/{tests => }/app.test.js (68%) create mode 100644 assignments/hackyourtemperature/babel.config.cjs create mode 100644 assignments/hackyourtemperature/jest.config.js diff --git a/assignments/hackyourtemperature/.env b/assignments/hackyourtemperature/.env new file mode 100644 index 000000000..64556074b --- /dev/null +++ b/assignments/hackyourtemperature/.env @@ -0,0 +1,2 @@ +BASE_URL=https://api.openweathermap.org/data/2.5 + API_KEY=62faffe5fe398983e589d80625a41622 \ No newline at end of file diff --git a/assignments/hackyourtemperature/.gitignore b/assignments/hackyourtemperature/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/assignments/hackyourtemperature/.gitignore.js b/assignments/hackyourtemperature/.gitignore.js deleted file mode 100644 index 2eea525d8..000000000 --- a/assignments/hackyourtemperature/.gitignore.js +++ /dev/null @@ -1 +0,0 @@ -.env \ No newline at end of file diff --git a/assignments/hackyourtemperature/app.js b/assignments/hackyourtemperature/app.js index 70b51aa06..ed71b234b 100644 --- a/assignments/hackyourtemperature/app.js +++ b/assignments/hackyourtemperature/app.js @@ -16,10 +16,12 @@ app.get('/', async (req, res) => { // Post route to fetch weather data app.post('/weather', async (req, res) => { - const { cityName } = req.body; // Extract city name from request body - + // Extract city name from request body + const { cityName } = req.body; + + // Validate the request if (!cityName) { - return res.status(400).json({ message: "City name is required" }); // Validate the request + return res.status(400).json({ weatherText: "City name is required" }); } try { // Fetch weather data from OpenWeatherMap API using provided city name and API key @@ -28,18 +30,20 @@ app.post('/weather', async (req, res) => { ); const data = await response.json(); + if (data.cod !== 200) { - return res.status(404).json({ message: "City is not found" }); + return res.status(404).json({ weatherText: "City is not found" }); } // return fetched weather data res.json({ - cityName : data.name, - temprature : data.main.temp + temperature: data.main.temp, + weatherText: `The temperature in ${data.name} is ${data.main.temp}°C` + }); } catch (error) { - res.status(500).json({ message: "Server error" }); + res.status(500).json({ weatherText: "Server error" }); } }); export default app; \ No newline at end of file diff --git a/assignments/hackyourtemperature/tests/app.test.js b/assignments/hackyourtemperature/app.test.js similarity index 68% rename from assignments/hackyourtemperature/tests/app.test.js rename to assignments/hackyourtemperature/app.test.js index b746be844..a0a06400c 100644 --- a/assignments/hackyourtemperature/tests/app.test.js +++ b/assignments/hackyourtemperature/app.test.js @@ -1,6 +1,6 @@ // Import required modules for testing import request from "supertest"; -import app from "../app.js"; +import app from "./app.js"; // Define test suite for POST /weather route describe("POST /weather" , () => { @@ -10,8 +10,9 @@ describe("POST /weather" , () => { .send({ cityName: "London" }); expect(response.status).toBe(200); - expect(response.body).toHaveProperty("cityName"); - expect(response.body).toHaveProperty("temprature"); + expect(response.body).toHaveProperty("temperature"); + expect(response.body.temperature).toBeGreaterThan(-50); + expect(response.body.temperature).toBeLessThan(60); }); it("should return an error for an invalid city", async () => { @@ -20,7 +21,7 @@ describe("POST /weather" , () => { .send({ cityName: "InvalidCity" }); expect(response.status).toBe(404); - expect(response.body.message).toContain("City"); + expect(response.body).toHaveProperty("weatherText", "City is not found"); }); it("should return an error for an empty city", async () => { @@ -29,7 +30,7 @@ describe("POST /weather" , () => { .send({ cityName: "" }); expect(response.status).toBe(400); - expect(response.body).toHaveProperty("message", "City name is required"); + expect(response.body).toHaveProperty("weatherText", "City name is required"); }); }); diff --git a/assignments/hackyourtemperature/babel.config.cjs b/assignments/hackyourtemperature/babel.config.cjs new file mode 100644 index 000000000..fbb629af6 --- /dev/null +++ b/assignments/hackyourtemperature/babel.config.cjs @@ -0,0 +1,13 @@ +module.exports = { + presets: [ + [ + // This is a configuration, here we are telling babel what configuration to use + "@babel/preset-env", + { + targets: { + node: "current", + }, + }, + ], + ], +}; diff --git a/assignments/hackyourtemperature/jest.config.js b/assignments/hackyourtemperature/jest.config.js new file mode 100644 index 000000000..19ba9649e --- /dev/null +++ b/assignments/hackyourtemperature/jest.config.js @@ -0,0 +1,8 @@ +export default { + // Tells jest that any file that has 2 .'s in it and ends with either js or jsx should be run through the babel-jest transformer + transform: { + "^.+\\.jsx?$": "babel-jest", + }, + // By default our `node_modules` folder is ignored by jest, this tells jest to transform those as well + transformIgnorePatterns: [], +}; diff --git a/assignments/hackyourtemperature/package.json b/assignments/hackyourtemperature/package.json index c17cef95b..a82ad588e 100644 --- a/assignments/hackyourtemperature/package.json +++ b/assignments/hackyourtemperature/package.json @@ -2,15 +2,14 @@ "name": "hackyourtemperature", "version": "1.0.0", "main": "server.js", - "type": "module", "scripts": { "test": "jest", "start": "node server.js" }, "keywords": [], + "type": "module", "author": "ahmadi.samira6761@gmail.com", "license": "ISC", - "description": "", "dependencies": { "dotenv": "^16.4.7", "express": "^4.21.2", @@ -21,8 +20,13 @@ "@babel/core": "^7.26.9", "@babel/preset-env": "^7.26.9", "babel-jest": "^29.7.0", + "cross-env": "^7.0.3", "jest": "^29.7.0", "supertest": "^7.0.0", "ts-jest": "^29.2.6" - } + }, + "directories": { + "test": "tests" + }, + "description": "" } diff --git a/assignments/hackyourtemperature/server.js b/assignments/hackyourtemperature/server.js index d7e32d2d7..eeef154bf 100644 --- a/assignments/hackyourtemperature/server.js +++ b/assignments/hackyourtemperature/server.js @@ -3,6 +3,6 @@ import app from './app.js'; const PORT = 3000; // Start the server on the specified port -app.listen(PORT , () => { +app.listen(PORT, () => { console.log(`Server is runnig on port ${PORT}`); }); \ No newline at end of file diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index b6039435f..e5aa7611c 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -2,6 +2,6 @@ import dotenv from "dotenv"; dotenv.config(); export default { - BASE_URL: process.env.BASE_URL, - API_KEY: process.env.API_KEY, + BASE_URL:process.env.BASE_URL, + API_KEY:process.env.API_KEY, }; From af5462836247dd6a8976c22060329a1c013b9a59 Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 20:43:32 +0100 Subject: [PATCH 10/16] New update --- assignments/config-files/babel.config.cjs | 13 ----- assignments/config-files/jest.config.js | 8 --- assignments/hackyourtemperature/.gitignore | 1 + assignments/hackyourtemperature2/.env | 2 - assignments/hackyourtemperature2/.gitignore | 0 assignments/hackyourtemperature2/app.js | 49 ------------------- assignments/hackyourtemperature2/app.test.js | 36 -------------- .../config-files/babel.config.cjs | 13 ----- .../config-files/jest.config.js | 8 --- assignments/hackyourtemperature2/package.json | 32 ------------ assignments/hackyourtemperature2/server.js | 8 --- .../hackyourtemperature2/sources/keys.js | 7 --- 12 files changed, 1 insertion(+), 176 deletions(-) delete mode 100644 assignments/config-files/babel.config.cjs delete mode 100644 assignments/config-files/jest.config.js delete mode 100644 assignments/hackyourtemperature2/.env delete mode 100644 assignments/hackyourtemperature2/.gitignore delete mode 100644 assignments/hackyourtemperature2/app.js delete mode 100644 assignments/hackyourtemperature2/app.test.js delete mode 100644 assignments/hackyourtemperature2/config-files/babel.config.cjs delete mode 100644 assignments/hackyourtemperature2/config-files/jest.config.js delete mode 100644 assignments/hackyourtemperature2/package.json delete mode 100644 assignments/hackyourtemperature2/server.js delete mode 100644 assignments/hackyourtemperature2/sources/keys.js diff --git a/assignments/config-files/babel.config.cjs b/assignments/config-files/babel.config.cjs deleted file mode 100644 index fbb629af6..000000000 --- a/assignments/config-files/babel.config.cjs +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - presets: [ - [ - // This is a configuration, here we are telling babel what configuration to use - "@babel/preset-env", - { - targets: { - node: "current", - }, - }, - ], - ], -}; diff --git a/assignments/config-files/jest.config.js b/assignments/config-files/jest.config.js deleted file mode 100644 index 19ba9649e..000000000 --- a/assignments/config-files/jest.config.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - // Tells jest that any file that has 2 .'s in it and ends with either js or jsx should be run through the babel-jest transformer - transform: { - "^.+\\.jsx?$": "babel-jest", - }, - // By default our `node_modules` folder is ignored by jest, this tells jest to transform those as well - transformIgnorePatterns: [], -}; diff --git a/assignments/hackyourtemperature/.gitignore b/assignments/hackyourtemperature/.gitignore index e69de29bb..2eea525d8 100644 --- a/assignments/hackyourtemperature/.gitignore +++ b/assignments/hackyourtemperature/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/assignments/hackyourtemperature2/.env b/assignments/hackyourtemperature2/.env deleted file mode 100644 index 64556074b..000000000 --- a/assignments/hackyourtemperature2/.env +++ /dev/null @@ -1,2 +0,0 @@ -BASE_URL=https://api.openweathermap.org/data/2.5 - API_KEY=62faffe5fe398983e589d80625a41622 \ No newline at end of file diff --git a/assignments/hackyourtemperature2/.gitignore b/assignments/hackyourtemperature2/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/assignments/hackyourtemperature2/app.js b/assignments/hackyourtemperature2/app.js deleted file mode 100644 index ed71b234b..000000000 --- a/assignments/hackyourtemperature2/app.js +++ /dev/null @@ -1,49 +0,0 @@ -// Import necessary modules -import express from 'express'; -import fetch from 'node-fetch'; -import keys from './sources/keys.js'; - -// Initialize Express app -const app = express(); - -// Middleware to parse JSON request bodies -app.use(express.json()); - -// Define a simple GET route -app.get('/', async (req, res) => { - res.send("Hello from backend to frontend") -}); - -// Post route to fetch weather data -app.post('/weather', async (req, res) => { - // Extract city name from request body - const { cityName } = req.body; - - // Validate the request - if (!cityName) { - return res.status(400).json({ weatherText: "City name is required" }); - } - try { - // Fetch weather data from OpenWeatherMap API using provided city name and API key - const response = await fetch( - `https://api.openweathermap.org/data/2.5/weather?q=${cityName}&appid=${keys.API_KEY}&units=metric` - ); - const data = await response.json(); - - - if (data.cod !== 200) { - return res.status(404).json({ weatherText: "City is not found" }); - } - - // return fetched weather data - res.json({ - temperature: data.main.temp, - weatherText: `The temperature in ${data.name} is ${data.main.temp}°C` - - }); - - } catch (error) { - res.status(500).json({ weatherText: "Server error" }); - } -}); -export default app; \ No newline at end of file diff --git a/assignments/hackyourtemperature2/app.test.js b/assignments/hackyourtemperature2/app.test.js deleted file mode 100644 index a0a06400c..000000000 --- a/assignments/hackyourtemperature2/app.test.js +++ /dev/null @@ -1,36 +0,0 @@ -// Import required modules for testing -import request from "supertest"; -import app from "./app.js"; - -// Define test suite for POST /weather route -describe("POST /weather" , () => { - it("should return weather data for a valid city", async () => { - const response = await request(app) - .post('/weather') - .send({ cityName: "London" }); - - expect(response.status).toBe(200); - expect(response.body).toHaveProperty("temperature"); - expect(response.body.temperature).toBeGreaterThan(-50); - expect(response.body.temperature).toBeLessThan(60); - }); - - it("should return an error for an invalid city", async () => { - const response = await request(app) - .post('/weather') - .send({ cityName: "InvalidCity" }); - - expect(response.status).toBe(404); - expect(response.body).toHaveProperty("weatherText", "City is not found"); - }); - - it("should return an error for an empty city", async () => { - const response = await request(app) - .post('/weather') - .send({ cityName: "" }); - - expect(response.status).toBe(400); - expect(response.body).toHaveProperty("weatherText", "City name is required"); - }); -}); - diff --git a/assignments/hackyourtemperature2/config-files/babel.config.cjs b/assignments/hackyourtemperature2/config-files/babel.config.cjs deleted file mode 100644 index fbb629af6..000000000 --- a/assignments/hackyourtemperature2/config-files/babel.config.cjs +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - presets: [ - [ - // This is a configuration, here we are telling babel what configuration to use - "@babel/preset-env", - { - targets: { - node: "current", - }, - }, - ], - ], -}; diff --git a/assignments/hackyourtemperature2/config-files/jest.config.js b/assignments/hackyourtemperature2/config-files/jest.config.js deleted file mode 100644 index d77f65019..000000000 --- a/assignments/hackyourtemperature2/config-files/jest.config.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - // Tells jest that any file that has 2 .'s in it and ends with either js or jsx should be run through the babel-jest transformer - transform: { - "^.+\\.jsx?$": "babel-jest", - }, - // By default our `node_modules` folder is ignored by jest, this tells jest to transform those as well - transformIgnorePatterns: [], -}; diff --git a/assignments/hackyourtemperature2/package.json b/assignments/hackyourtemperature2/package.json deleted file mode 100644 index 4fb15f373..000000000 --- a/assignments/hackyourtemperature2/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "hackyourtemperature", - "version": "1.0.0", - "main": "server.js", - "scripts": { - "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", - "start": "node server.js" - }, - "keywords": [], - "type": "module", - "author": "ahmadi.samira6761@gmail.com", - "license": "ISC", - "dependencies": { - "dotenv": "^16.4.7", - "express": "^4.21.2", - "express-handlebars": "^8.0.1", - "node-fetch": "^2.7.0" - }, - "devDependencies": { - "@babel/core": "^7.26.9", - "@babel/preset-env": "^7.26.9", - "babel-jest": "^29.7.0", - "cross-env": "^7.0.3", - "jest": "^29.7.0", - "supertest": "^7.0.0", - "ts-jest": "^29.2.6" - }, - "directories": { - "test": "tests" - }, - "description": "" -} diff --git a/assignments/hackyourtemperature2/server.js b/assignments/hackyourtemperature2/server.js deleted file mode 100644 index eeef154bf..000000000 --- a/assignments/hackyourtemperature2/server.js +++ /dev/null @@ -1,8 +0,0 @@ -import app from './app.js'; - -const PORT = 3000; - -// Start the server on the specified port -app.listen(PORT, () => { - console.log(`Server is runnig on port ${PORT}`); -}); \ No newline at end of file diff --git a/assignments/hackyourtemperature2/sources/keys.js b/assignments/hackyourtemperature2/sources/keys.js deleted file mode 100644 index e5aa7611c..000000000 --- a/assignments/hackyourtemperature2/sources/keys.js +++ /dev/null @@ -1,7 +0,0 @@ -import dotenv from "dotenv"; -dotenv.config(); - -export default { - BASE_URL:process.env.BASE_URL, - API_KEY:process.env.API_KEY, -}; From 47e684394b7e6408260529be6551cef6143f6202 Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 20:51:38 +0100 Subject: [PATCH 11/16] Added new update --- assignments/hackyourtemperature/.env | 2 -- assignments/hackyourtemperature/sources/keys.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 assignments/hackyourtemperature/.env diff --git a/assignments/hackyourtemperature/.env b/assignments/hackyourtemperature/.env deleted file mode 100644 index 64556074b..000000000 --- a/assignments/hackyourtemperature/.env +++ /dev/null @@ -1,2 +0,0 @@ -BASE_URL=https://api.openweathermap.org/data/2.5 - API_KEY=62faffe5fe398983e589d80625a41622 \ No newline at end of file diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index e5aa7611c..061b047a6 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -2,6 +2,6 @@ import dotenv from "dotenv"; dotenv.config(); export default { - BASE_URL:process.env.BASE_URL, - API_KEY:process.env.API_KEY, + BASE_URL: "https://api.openweathermap.org/data/2.5", + API_KEY:"62faffe5fe398983e589d80625a41622", }; From 5a14a127de792e7ca36368bab00086a965fd716b Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 20:54:03 +0100 Subject: [PATCH 12/16] Added new update --- assignments/hackyourtemperature/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/assignments/hackyourtemperature/.gitignore b/assignments/hackyourtemperature/.gitignore index 2eea525d8..e69de29bb 100644 --- a/assignments/hackyourtemperature/.gitignore +++ b/assignments/hackyourtemperature/.gitignore @@ -1 +0,0 @@ -.env \ No newline at end of file From 448b7956334d91d5261eb912f7e17daf531fc4f6 Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 21:03:17 +0100 Subject: [PATCH 13/16] Added new update --- assignments/hackyourtemperature/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/assignments/hackyourtemperature/.gitignore b/assignments/hackyourtemperature/.gitignore index e69de29bb..2eea525d8 100644 --- a/assignments/hackyourtemperature/.gitignore +++ b/assignments/hackyourtemperature/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file From 0c5ecce4f757a392fc6cb85d1f2351643ac5f96e Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 21:12:32 +0100 Subject: [PATCH 14/16] Added new update --- assignments/hackyourtemperature/sources/keys.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignments/hackyourtemperature/sources/keys.js b/assignments/hackyourtemperature/sources/keys.js index 061b047a6..e5aa7611c 100644 --- a/assignments/hackyourtemperature/sources/keys.js +++ b/assignments/hackyourtemperature/sources/keys.js @@ -2,6 +2,6 @@ import dotenv from "dotenv"; dotenv.config(); export default { - BASE_URL: "https://api.openweathermap.org/data/2.5", - API_KEY:"62faffe5fe398983e589d80625a41622", + BASE_URL:process.env.BASE_URL, + API_KEY:process.env.API_KEY, }; From 44bddd7f9f8378f3630fa4adcd009d2f3eba9128 Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 21:30:10 +0100 Subject: [PATCH 15/16] updated changes --- assignments/hackyourtemperature/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 assignments/hackyourtemperature/.gitignore diff --git a/assignments/hackyourtemperature/.gitignore b/assignments/hackyourtemperature/.gitignore deleted file mode 100644 index 2eea525d8..000000000 --- a/assignments/hackyourtemperature/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.env \ No newline at end of file From 6e8dcd4ef0c148d1d1572c9e73ad2bfcecf526d1 Mon Sep 17 00:00:00 2001 From: Samira Date: Fri, 7 Mar 2025 21:30:59 +0100 Subject: [PATCH 16/16] updated changes --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b6b402ed9..339aed723 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ yarn-error.log *.bkp week3/prep-exercise/server-demo/ + +.env