diff --git a/Existing_API_Collection/CountryAPI/.vscode/settings.json b/Existing_API_Collection/CountryAPI/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/Existing_API_Collection/CountryAPI/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/Existing_API_Collection/CountryAPI/country.css b/Existing_API_Collection/CountryAPI/country.css index c92870e..f26c967 100644 --- a/Existing_API_Collection/CountryAPI/country.css +++ b/Existing_API_Collection/CountryAPI/country.css @@ -77,3 +77,14 @@ body{ color: #ff465a; } +#clear-btn +{ + font-size: 1em; + background-color: #3d64e6; + color: #ffffff; + padding: 0.8em 0; + border: none; + border-radius: 1.5em; + cursor: pointer; + width: 8em; +} \ No newline at end of file diff --git a/Existing_API_Collection/CountryAPI/country.html b/Existing_API_Collection/CountryAPI/country.html index fa8c4bb..26c33e7 100644 --- a/Existing_API_Collection/CountryAPI/country.html +++ b/Existing_API_Collection/CountryAPI/country.html @@ -15,7 +15,6 @@
- \ No newline at end of file diff --git a/Existing_API_Collection/CountryAPI/country.js b/Existing_API_Collection/CountryAPI/country.js index 6627091..b2dfe30 100644 --- a/Existing_API_Collection/CountryAPI/country.js +++ b/Existing_API_Collection/CountryAPI/country.js @@ -50,7 +50,9 @@ searchBtn.addEventListener("click",()=>{

Common Languages :

${Object.values(data[0].languages).toString().split(",").join(", ")} - `; + + + `; }) .catch(()=>{ if(countryName.length == 0){ @@ -60,4 +62,11 @@ searchBtn.addEventListener("click",()=>{ result.innerHTML=`

Please enter a valid country name.

`; } }); -}); \ No newline at end of file +}); + +document.addEventListener("click", function(e) { + if (e.target && e.target.id === "clear-btn") { + result.innerHTML = ""; + } +}); + diff --git a/Existing_API_Collection/GiphyAPI/style.css b/Existing_API_Collection/GiphyAPI/style.css index 29e71a3..d2ec76b 100644 --- a/Existing_API_Collection/GiphyAPI/style.css +++ b/Existing_API_Collection/GiphyAPI/style.css @@ -53,12 +53,14 @@ main { #gif-container { display: flex; flex-wrap: wrap; + padding: 50px 80px; justify-content: center; } .gif-item { margin: 10px; - max-width: 250px; + max-width: fit-content; + height: fit-content; text-align: center; background-color: #fff; border: 1px solid #ddd; diff --git a/New_APIs/Demo_CRUD_API/package.json b/New_APIs/Demo_CRUD_API/package.json index 7d443e2..d26f152 100644 --- a/New_APIs/Demo_CRUD_API/package.json +++ b/New_APIs/Demo_CRUD_API/package.json @@ -5,9 +5,9 @@ "main": "dist/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build" : "tsc ", - "start" : "tsc & node .", - "dev" : "tsc -w & nodemon ." + "build": "tsc ", + "start": "tsc & node .", + "dev": "tsc -w & nodemon ." }, "keywords": [], "author": "", diff --git a/New_APIs/Demo_CRUD_API/src/index.js b/New_APIs/Demo_CRUD_API/src/index.js index fe534f9..495648b 100644 --- a/New_APIs/Demo_CRUD_API/src/index.js +++ b/New_APIs/Demo_CRUD_API/src/index.js @@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); var express = require('express'); var dotenv = require('dotenv'); dotenv.config(); -var app = express(); -var port = process.env.PORT || 3000; +const app = express(); +const port = process.env.PORT || 3000; app.use(express.json()); //Middleware -var users = [ +const users = [ { "id": 1, "name": 'Johnny1' @@ -26,7 +26,7 @@ app.get("/user", function (req, res) { }); //CREATE USER app.post("/user", function (req, res) { - var newUser = { + const newUser = { name: req.body.name, id: Date.now(), }; @@ -35,7 +35,7 @@ app.post("/user", function (req, res) { }); //UPDATE app.put("/user", function (req, res) { - var _a = req.body, id = _a.id, name = _a.name; + let _a = req.body, id = _a.id, name = _a.name; users = users.map(function (user) { if (user.id === id) { user.name = name; @@ -45,12 +45,12 @@ app.put("/user", function (req, res) { }); //DELETE app.delete("/user/:id", function (req, res) { - var id = req.params.id; + let id = req.params.id; users = users.filter(function (user) { return user.id !== Number(id); }); res.json(users); }); var isAuthorized = function (req, res, next) { - var authHeader = req.headers.authorization; + const authHeader = req.headers.authorization; if (authHeader === 'gdscdemocrudapi') { next(); } @@ -61,8 +61,8 @@ var isAuthorized = function (req, res, next) { }; //GET USER BY ID app.get("/user/:id", isAuthorized, function (req, res) { - var id = req.params.id; - var user = users.find(function (user) { return user.id === Number(id); }); + let id = req.params.id; + const user = users.find(function (user) { return user.id === Number(id); }); res.json(user); }); //Start the app