From 68e4ef71af7609ccc6d9d624c33f6a0e30a43c66 Mon Sep 17 00:00:00 2001 From: HRUSHIKESH DOKALA <96101829+Hk669@users.noreply.github.com> Date: Sat, 13 Jul 2024 00:57:34 +0530 Subject: [PATCH] chore: Improvements (#10) * feat: store env variables * 1. fetch repos based on user query everytime --- client/package-lock.json | 23 +++++++++++++++++++---- client/package.json | 3 +++ client/src/App.jsx | 17 ++++++++++------- client/src/components/Input/Input.jsx | 2 +- client/src/components/Login/Login.jsx | 8 +++++--- src/api.py | 14 +++++++++----- src/search.py | 2 +- 7 files changed, 48 insertions(+), 21 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 2f90802..39f1cbf 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -22,6 +22,9 @@ "react-scripts": "5.0.1", "react-toastify": "^10.0.5", "web-vitals": "^2.1.4" + }, + "devDependencies": { + "dotenv": "^16.4.5" } }, "node_modules/@adobe/css-tools": { @@ -7190,11 +7193,15 @@ } }, "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, "engines": { - "node": ">=10" + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" } }, "node_modules/dotenv-expand": { @@ -15178,6 +15185,14 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/react-toastify": { "version": "10.0.5", "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-10.0.5.tgz", diff --git a/client/package.json b/client/package.json index 59769a8..b60cac6 100644 --- a/client/package.json +++ b/client/package.json @@ -41,5 +41,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "dotenv": "^16.4.5" } } diff --git a/client/src/App.jsx b/client/src/App.jsx index 17d0028..89e0a96 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -23,13 +23,16 @@ function App() { const token = localStorage.getItem("jwt_token"); if (token) { try { - const response = await fetch(`http://127.0.0.1:8000/verify-token`, { - method: "GET", - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "application/json", - }, - }); + const response = await fetch( + `${process.env.REACT_APP_API_URL}/verify-token`, + { + method: "GET", + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "application/json", + }, + } + ); if (response.ok) { const data = await response.json(); setIsAuthenticated(true); diff --git a/client/src/components/Input/Input.jsx b/client/src/components/Input/Input.jsx index 511b396..c515d30 100644 --- a/client/src/components/Input/Input.jsx +++ b/client/src/components/Input/Input.jsx @@ -32,7 +32,7 @@ const Input = ({ onSubmit }) => { try { const response = await axios.post( - `http://127.0.0.1:8000/api/recommendations/`, + `${process.env.REACT_APP_API_URL}/api/recommendations/`, { username: username, languages: languages, diff --git a/client/src/components/Login/Login.jsx b/client/src/components/Login/Login.jsx index 7bb23d2..fb5f811 100644 --- a/client/src/components/Login/Login.jsx +++ b/client/src/components/Login/Login.jsx @@ -3,9 +3,11 @@ import React from "react"; import "./Login.css"; import { FaGithub } from "react-icons/fa"; +const API_URL = process.env.REACT_APP_API_URL; + const Login = () => { const handleLogin = () => { - window.location.href = `http://127.0.0.1:8000/github-login`; + window.location.href = `${API_URL}/github-login`; }; return ( @@ -59,8 +61,8 @@ const Login = () => { your skills and interests.